Reputation: 3219
The project structure is like this
Now as Module 1 and 2 has their own Activity which needs to be invoked from Main Module, there rises an problem with circular dependency. Main Module needs to invoke Activity from Module 1 and Module 1 needs some code from Main.
So how to resolve these kind of dependency problem in Android Studio using gradle ?
Upvotes: 4
Views: 8854
Reputation: 1210
You can do this via an implicit Intent
.
Let's say you want Activity1 in Module1 to start Activity2 in Module2, but you can't because that would cause a circular dependency.
Go to the AndroidManifest.xml
in Module2 and set android:exported="true"
as a property on the Activity2. Then, in Activity1, do this:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example.module2", "com.example.module2.Activity2"));
startActivity(intent);
finish();
Upvotes: 3
Reputation: 3687
Move the common code used by the two enhancement modules to another module, and create two application modules:
common
enhancement 1
depends on common
enhancement 2
depends on common
app 1
depends on enhancement 1
app 2
depends on enhancement 2
If needed created another module common-app
to contain the common code shared between the two applications.
Upvotes: 3