I've been having issues adding a submodule to my android project. I've tried all tutorials and some solutions available online but none exactly says what to do add a submodule and also keep your commits on it in sync with the main repo.
Solutions I've tried:
TO FIX THIS: I added implementation project(':Tools_Demo_App')
in my build.gradle dependancies, then it shows this error.
Then, if I add include ':Tools_Demo_App'
to my settings.gradle. This error goes away.
But still, I'm not able to add an activity. It says "Java file outside of source root".
No matter what I do, so far none of the tutorials available online has helped. Please suggest something, if you've worked with submodules and was able to work with them keeping everything in sync with main repo.
What actually I want to do:
Main Project: A submodule: demo I want to keep demo repo as a base app to keep all my designs, libraries and templates so that I can just add this submodule to all my projects and just pick reusable stuff from here instead of rewriting everything everytime.
I figured out the ideal solution to this. My project name: A submodule name: x
terminal
git submodule add github-link-to-submodule-x
git submodule update --init --recursive
settings.gradle
include ':app'
rootProject.name = "TutorialKotlin"
include ':Tools_Demo_App'
project(':Tools_Demo_App').projectDir = new File('Tools_Demo_App/app')
build.gradle
implementation project(':Tools_Demo_App')
build.gradle of library module
change
apply plugin: 'com.android.application'
to apply plugin: 'com.android.library'
remove applicationId
make sure there is no launcher activity in AndroidManifest.xml
sync the project and it works fine.