There are two applications (projects) that use the same library (a project with the Android Library module).
The App communicates with USB_Lib by direct calling methods, and USB_Lib with the App via the interface with a callback. When applications are working one by one, everything is in order, but when both are launched, then a conflict over access to the resource (USB) begins. Moreover, it became necessary to launch App2 when launching App1 and to switch them by flipping through the screen. The first thing that came to mind is to expand the interface USB_Lib for App2
but somehow the bones turn out: transmit and analyze the contents of the received data from USB_Lib twice , and the module itself should work with only one application.
I decided to go another way:
and import App2 into the App1 project.
This raises the question of how to build one application, the project of which consists of one library module and two application modules with different packages, and do you need to write something else in the gradle in this case? The main thing is to preserve the autonomy of the App2 project, i.e. open the project, fix the code and debug. App1 will always contain App2 and run it depending on the settings, but App2 should be able to work as a separate application. In any case, the device is installed either only App1 (with embedded App2), or only App2.
Who has any ideas?
PS: I considered the option to make USB_Lib as a Service, but there is no need to keep it in memory all the time, and it will turn out like along the interface extension path, though ..


