8

Environment Configuration

  • com.android.tools.build:gradle:0.4
  • gradle version 1.6
  • jdk 1.6 (OSX)
  • android build tools version 17
  • compile sdk version 17

The issue that I seem to be having is that I can’t seem to exclude lombok from being added to the apk. I tried to do it by creating a provided configuration like this:

configurations {
   provided
}

sourceSets {
   main { compileClasspath += configurations.provided }
}

and then adding the dependency like this:

dependencies {
     provided ‘org.projectlombok:lombok:0.11.8′
}

But I’m still getting this error:

Error: duplicate files during packaging of APK <myapp>.apk
Path in archive: LICENSE
Origin 1: /<home>/.gradle/caches/artifacts-24/filestore/org.projectlombok/lombok/0.11.8/jar/e43ce2be16d8990568a4182c0bf996ad3ff0ba42/lombok-0.11.8.jar
Origin 2: /<home>/.gradle/caches/artifacts-24/filestore/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/jar/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
:packageRelease FAILED

I have tried using lombok-api.jar which then causes a different issue regarding some AccessLevel annotation while performing dex.

Which suggests that its including the lombok jar file into the apk. This shouldn't be happening, any suggestions?

1 Answer 1

6

You can't use sourceSets because we use custom ones. You'd have to do the following:

android.applicationVariants.each { variant ->
    variant.javaCompile.classpath += configurations.provided.
}

However, it should be possible to instead remove the dependency from our "package" config (which replaces the "runtime" one.) I'll look into it.

8
  • 1
    Thanks for the reply, i've made the changes you've suggested but i'm still getting the same error, my feeling is that the gradle plugin must be using the compileClassPath as some kind of include path somewhere, if there is a way to exclude libraries from being imported into the apk that would be great, we need to use this for mobeam later this year too. Commented May 20, 2013 at 9:59
  • 1
    sorry for the confusion, i just realised i had a dependency pulling in lombok too, i've now excluded it from that library dependency and still have the gradle code configured the way you've listed here, but now i seems that the library is missing from the compile path when executing compileRelease Commented May 20, 2013 at 11:38
  • FYI, printing out android.applicationVariants, gives me a empty array (ex []), dont know if that helps. I've been searching for more information about applicationVariants, seems it was first buildVariants and now its applicationVariants. Seems there has been a lot of changes between 0.3 and 0.4 of this build tool, the documentation on the site still refers to 0.3 Commented May 20, 2013 at 12:15
  • 2
    I confirm that this is currently broken. We are working on a fix that'll go out quickly. Commented May 22, 2013 at 1:49
  • 1
    @Xav i seem to be having problems with android studio not picking up this modified compile classpath. Is it possible to rather exclude a specific lib from being packaged with the apk? Commented Jun 10, 2013 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.