In my Android application I've created a new library module. Now I have this structure:

Right now I have under version control on Bitbucket whole project less datingcorelib. I would like to use a different repo to this library module.
It's possible to use two different repos on the same project?
Yes, it is possible. You're looking for a thing called submodule.
However, it may be tricky to use such a submodule within a project as it will have its own structure. So you also need to include the right gradle project from that submodule.
Let's say you pushed your library project somewhere. Let it be [email protected]:Sami/my-library.git. We also assume that it has the common structure for Android library project, i.e. it has a root build.gradle file and a subfolder datingcorelib with actual source code. This is what we need to include into the app.
You need to delete datingcorelib from your app's project. Then add the library as a submodule:
git submodule add [email protected]:Sami/my-library.git libraries/datingcorelib
After that open settings.gradle file of your app's project and add a new line there:
project(':datingcorelib').projectDir = new File("$rootDir/libraries/datingcorelib/datingcorelib")
Sync the project. Now you should be able to use the code from another repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With