Hello, during the development of an application for Android, the following problem arose:
there are java files that are designed to implement the logic for connecting to a device such as 1, they are in package Device1 (there are also subpackages inside this package), other java files are in package Device2 .
Each package ( Device1 , Device2 ) has java files with the same name, for example Func . The packages Device1 , Device2 should work independently of each other. Those. Device1 package files cannot reference Func from Device2 package and vice versa.
There is also the CommonConnection package, which implements the initial connection to the packages Device1 , Device2 . In this case, the CommonConnection package should have access to all other packages of both Device1 and Device2 .
Is it possible to somehow prohibit files from the Device1 package to refer to files from the Device2 package and vice versa, so that by mistake when entering auto-completion you do not enter the file from someone else's package, while the common CommonConnection package can access both the Device1 package files and Device2 files?
Thank you in advance for all the answers.
Created modules Device1, Device2, CommonConnection . In build.gradle for CommonConnection introduced dependencies for Device1, Device2 eventually got an error.
I summarize here the solution to my problem, maybe someone will come in handy in the future:
1) Create 3 modes for CommonConnection, Device1, Device2 . We need the files in CommonConnection to have access to Device1, Device2 . And Device1, Device2 were isolated from each other, i.e. the file from Device1 could not have access to Device2 . 2) After creating the modules, go to gradle for Device1 and make the following changes:
**apply plugin: 'com.android.application'** change to apply plugin: 'com.android.library'
And in defaultConfig, remove the line applicationId "com.bignerdranch.android.Device1"
3) For Device2, you need to do the same. 4) In the gradle file for CommonConnection , add the line compile project (': Device1')
5) Next, you need to explicitly indicate that you need to start the activation of the CommonConnection module initially . Click on Select Run / Debug Configuration and select the CommonConnection module. Next, once again click on Select Run / Debug Configuration -> EditConfigurations .. ** in the ** Launch Options menu in the Activity row click on ... and select activations for CommonConnection in particular MainActivityCommonConnection .
6) Now you can run the project and check.



