Search code examples
androidgitversion-controlgithubproject-organization

How should I organize source control for Android projects including libraries?


I need a little help figuring out the best way (or best practice) to organize my Android project. For simplicity sake, let's say my Eclipse workspace for Android is C:\Android\Projects\. Inside that folder I like to separated applications from libraries and I have two other folders, C:\Android\Projects\Applications and C:\Android\Projects\Components.

For one project I have cloned a library from GitHub into the Components folder, let's say C:\Android\Projects\Componentes\SampleLib (inside that folder there's two folders TheLib and TheLibExample). And my app is created into C:\Android\Projects\Applications\MyTestApp. Then I included the library into the app by following these instructions.

Now let's say I want to use GitHub to share my app with the open-source community. I'll create a repository and push everything from C:\Android\Projects\Applications\MyTestApp into some repository.

If someone wants to fork my app or even help me, it will need the library to compile and run it, which is not included in my project itself. The default.properties file will have something like android.library.reference.1=../Components/SampleLib/TheLib and that someone will need to manually clone that library too and he would need to place it in the same relative path, otherwise it would mess up source control for my app.

The only way I can think of solving this issue is to organize my workspace like this:

C:\Android\Projects\Applications\MyTestApp\TheApp
C:\Android\Projects\Applications\MyTestApp\TheLib
C:\Android\Projects\Componentes\SampleLib

And my repository should be filled with the contents from C:\Android\Projects\Applications\MyTestApp\.

But what happens when the library is updated? I can't simply pull the new changes, I need to copy those into TheLib folder. In the previous folder organization this would not be needed as I was referencing the original cloned repository and not a copy.

What should I do then? Should I go with option one and let anyone forking my project deal with the library dependency as they see fit, or should I go with the second one and give everyone more work by keeping two folders in sync when the original one pulls changes from the it's repository?


Solution

  • Maybe git submodules will solve your issue.