We have an app with bottom bar navigation. The navigation is in our MainActivity
. We manage navigation between the different screens of the app with fragments. E.g. there are:
- ProductFragment
- LoginFragment
- CartFragment
- ProfileFragment
- SearchFragment
In our MainActivity
we have a method pushFragment(Fragment fragment)
which is responsible for replacing the current fragment with a new fragment. Between our different fragments there are a lot of dependencies. E.g.:
- a user can start the
ProductFragment
from theCartFragment
- In order to see certain product data the user has to log in (
LoginFragment
) - the
LoginFragment
is also used from theProfileFragment
- Through "historic orders" in the
ProfileFragment
you can also display product details via theProductFragment
.
We now want to modularize our Android app to make use of Instant Apps, faster build times, and all the other advantages. Ideally we'd like to have a module for each fragment. However due to dependencies like the ones I just described we are not able to create a linear dependency hierachy and have no idea how to build our modules.
Every time we try to pick our first module to extract from the app module, we end up with a lot of dependencies we also have to move to the new module.
The only solution we currently see is to change the way we navigate between the fragments, but we can't think of a way on how to do that.