Android Gradle Plugin


About the new gradle plugin environment:

  • Developed by Google
  • Has replaced the ADT.
  • Extends the java gradle plugin.
  • Should sync better with ide builds (now with android studio, not eclipse).

Videos and resources:


Follow the instructions for the Android Development Environment.

About The Android Gradle Catkinization

  • Using only one package.xml per repo (leave the rest to gradle).
  • Sequencing of repo builds handled by catkin and package.xml depends.
  • Everything else done by the gradle android plugin
    • Runs assembleDebug or assembleRelease depending on the cmake build type.
    • Also runs an install step to dump .aar's (libraries) into the local maven repo.
  • Once you have done an initial catkin_make, source devel/setup.bash and you can just call gradle directly everywhere.

  • Rosjava_tools now includes three helper scripts
    • catkin_create_android_repo
    • catkin_create_android_pkg
    • catkin_create_android_library_pkg

Conclusions so Far ...

Command line:

  • The conversion from adt to gradle was almost bump free
    • Gradle builds are faster than our custom gradle tasks beforehand.
  • Library's build as .aar's now (zips containing classes.jar and resources).
  • Can create a custom task to dump .aar's into mavenLocal() easily, but
    • The real maven upload functionality coming soon.
  • We've dropped one layer of abstraction - no more adt! Wunderbar!


  • Bit of a surprise, basic eclipse gradle projects don't work properly
  • Official support moving to intelliJIdea based Android Studio.

    • Currently only v0.1.2
    • After overcoming the initial unfamiliarity, it seems to have everything we need.

Other Notes

Catkin Package.xml

Easiest way to work is just use one package.xml for each repo and let gradle handle all the sub projects. That saves having to maintain alot of messy catkin cmake.


Naming for both maven, java and android packages should follow the java packaging guidelines for uniqueness. The prefix com.github.ros_java.repo_name is probably a good standard to adopt. Maven names for android .aar's have a problem right now though as they don't respect the full name, just the base name, so make sure your base names are relatively unique till they get the maven android plugin worked out.

Differences Between Android Gradle and ADT

Just for informative purposes.

The new plugin mostly just does minor shifts from to gradle, and no more android update project calls are needed.

  • Need gradle 1.6 for android gradle plugin 0.4.
  • All folders by default now under src/main, e.g. src/main/java, src/main/resources.

    • AndroidManifest.xml also under src/main.

  • Point gradle at your android sdk via the ANDROID_HOME variable

  • Merging manifests is a bit more strict (particularly how android_core was specifying a NodeMainExecutor service in library and app - the app specification was lax).

  • Libraries need a dummy <application/> tag in them until a bug gets fixed (android gradle plugin version 0.5)

Wiki: sig/Rosjava/Android Gradle Plugin (last edited 2013-06-25 13:25:29 by DanielStonier)