Android, Gradle and compile-time only dependencies

Android plugin for Gradle does not support Java-style compile time only dependencies.

After spending a few hours on trying to build android app targeted for Amazon SDK (without using Amazon’s Android specific plugin but just their jar stubs for maps, ADM and Home widget), I finally found that the one way to support compile-time dependencies is following.

For application project

For the library project

References

  1. https://stackoverflow.com/questions/16613722/gradle-configurations-not-working-as-expected-in-new-android-build-system
  2. http://stackoverflow.com/a/24157721

3 Replies to “Android, Gradle and compile-time only dependencies”

  1. It doesn’t work.

    This solution is working:

    android.libraryVariants.all { variant ->
    variant.outputs.each { output ->
    output.packageLibrary.exclude(‘libs/unity-classes.jar’)
    }
    }

  2. Thanks Eugene. I wrote it in Aug 2014, things might have changed since then.

Leave a Reply

Your email address will not be published. Required fields are marked *