At work, we have a project where an Android application depends on a Android library project for some theme files. The application project has a simple path to the library project, so they always have to be in the same position relative to each other. For reuseability the library project lives in its own Git repository. There are two possible ways of making this work on the both the local side and the server side:
One is to have the library project checked out as a submodule to the application project and make the path simply be the subfolder name. The advantage of this is that it will work equally well on the server (Jenkins) side and locally within a workspace. The disadvantage is that you can’t have more than one project using the library in our workspace, unless you modify the projects project.properties file. (Which quickly becomes a version control pain in the ass. It might be possible to modify local.properties instead, which I haven’t tested, but keeping machine-specific configs outside of version control also creeps me out.)
Now, I don’t know if this is Eclipse Best Practices, but I typically keep several Android projects in the same workspace since it makes it easier to jump between them when working. Therefore I prefer to have the library checked out as a top level project in the workspace, and all the projects referring to it have a path like “../TheLibrary”. This will, on the other hand, create problems for Jenkins when it checks out the project and then can’t find a folder in that location with the library. So I use the “Multiple SCMs” plugin to fetch both the application and the library, and set them up to checkout to separate directories within the build workspace. (Branches to build -> Advanced -> Local subdirectory for repo) Voila, we have recreated the essential parts of the Eclipse workspace and things will build happily without any differences between IDE and build server!
Right now managing Android libraries is quite difficult, and hopefully this will improve with the new Gradle based build system. Being able to package them in a binary format that you can drop into the project’s lib folder sounds like exactly the ticket for something that doesn’t change very often. Alternatively, I have been thinking about maybe setting up an inernal Maven repository to make things properly automagical!
Edit: I forgot to mention that if you set up an Android build with subdirectories like this, you will also have to go to Build Steps -> Invoke Ant -> Advanced and specify the build.xml file since it is no longer in the root.