I am new to Android Studio, Right now I have create a project and added a module in it as a library project but when i push the project to Git the library project gets also
i also had the same situation where i had to develop a library and the application in parallel. For this you can use android library project as git submodule to your application project, in that way you can manage both your application project and the library project.So here is my solution:
Step 1: create an android library project.
its similar to creating normal application project. just go through this google doc : https://developer.android.com/studio/projects/android-library.html
step 2: create a repository for the library project in git (GitHub/BitBucket)
step 3: add the library codes to the version control system (VCS)
step 4: push your library codes to the git repository
Step 5: now create your Android application project
Step 6: Add the project to version control system (VCS)
Step 7: From the bottom version control menu, add all the Unversioned Files to the VCS
Step 8: From android studio project terminal add git sub-module using command
git submodule add HHHH://XXX@bitbucket.org/YYY/ZZZ.git
make sure the sub module save location folder name is different than the original library project name, else you might get conflicts.
Step 9: You will get a message for 'unregisterd vcs root detected'. click on add root
now you can see multiple git repositories at the right bottom of the android studio
Step 10: goto file menu — project structure
Step 11: click ‘+’ on left top
Step 12: select ‘Import Gradle Project’
Step 13: select the sub-module folder
Step 14: give the actual sub-module project name
Step 15: Sync
Step 16: Now in the application project builg.gradle file add
compile project(‘:lib-name’)
within the dependencies section
Step 17: gradle sync & build project
Now you have an application project in git, which uses a library which is added to it as a submodule in git. Now you can develop on the application and on the library parallelly. Its better to keep a separate branch of the library for an application so as not to conflict with other application usage, and if the library code changes can be used in other projects also you can make a PR request to the main branch of the library.
Happy Coding :)
I have published this as my blog: https://medium.com/@deepakpk/how-to-add-a-git-android-library-project-as-a-sub-module-c713a653ab1f#.mt6dlng5n