State of Android project dependency management
Asked Answered
P

2

19

We are standardizing our infrastructure for Android development and we are trying to incorporate dependency management to our Android library projects. My current track is using the maven android plugin with m2e-android. We have uploaded the Android artifacts to our Artifactory repository with the Android SDK Deployer. We also have an internal framework with a few libraries we can import into our projects and for most part it works fine.

The issue we are facing now is that apklib dependencies containing resource files are hard to set up. The maven plugin can correctly configure the classpath but if the apklib has resource files that needs to be referenced by the parent Android project, Eclipse is unable to find them unless you checkout the Library Project and link it to the parent project through ADT.

After reading m2e-android discussion on issue https://github.com/rgladwell/m2e-android/issues/8, https://stackoverflow.com/questions/6269816/creating-closed-source-android-libraries#answer-6270768 and APKLIB does not get installed in Maven Repo, I'm not convinced maven is the way to go until ADT properly support closed source apk libraries.

I'd like to know how are you handling these kind of dependencies on your Android projects. What strategies are there other than using Maven?

For reference, here's what we have tried so far.

  1. No dependency management. All required jars are stored into the lib folder and pushed to the source control repo. Library projects are set up as subfolders and pushed to the source control repo for each project they are used in. Eclipse project settings are also pushed. Project built with standard ADT Ant script.
  2. Jar dependencies into libs folder and library dependencies as git submodules. Project built with standard ADT Ant script.
  3. Dependency management with maven, including library projects with apklib packaging. Issue with resource files in apklibs.
Pegboard answered 14/1, 2013 at 20:13 Comment(3)
You can group your library project and app project as a multi-module project, see sample here. when import the multi-module project into Eclipse, m2e-android will setup the library project and link to the app project automatically.Heptavalent
Cool I will try that. For the time being we decided to use ant macros to clone library projects from git. It does not solve dependency transitivity or the like but since our dependency graph is pretty shallow on Android it shouldn't be a problem most of the time. We made it so that it looks a little bit like maven/ivy/gradle. The macro is called "dependency" and we have a script we import with a task called update-dependencies. On your project script, all you gotta do is to add <dependency url="git url" name="directory name of the library" version="branch/tag to checkout"/>.Pegboard
We've been using Maven with IntelliJ. It handles apklib type dependencies (submodule or otherwise) like a champ. As an added bonus, the (free) community edition has been totally sufficient for our needs.Baxley
P
4

With the advent of Android Studio and Gradle, we are no longer facing issues with project dependencies; Android or otherwise.

Gradle supports Maven dependencies in jar or apklib formats. Popular libraries have been exported to the apklib (aar) format and made available through Maven.

Pegboard answered 11/8, 2014 at 19:0 Comment(0)
A
8

You can have an insight on how Facebook Android developers address their dependencies issues in this video: How Facebook Built Facebook for Android.

They use Buck for that. Buck is a build system for Android that encourages the creation of small, reusable modules consisting of code and resources. Buck is in github

This might not be the best solution for you but maybe for someone else.

Assiniboine answered 31/5, 2013 at 12:44 Comment(0)
P
4

With the advent of Android Studio and Gradle, we are no longer facing issues with project dependencies; Android or otherwise.

Gradle supports Maven dependencies in jar or apklib formats. Popular libraries have been exported to the apklib (aar) format and made available through Maven.

Pegboard answered 11/8, 2014 at 19:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.