Gradle Configurations not working as expected in the new Android Build system

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 problem that I seem to encounter is that I cannot rule out the possibility of adding a Lombock to apk. I tried to do this by creating a configuration like this:

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

and then adding the dependency as follows:

 dependencies { provided 'org.projectlombok:lombok:0.11.8β€² } 

But I still get 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 tried using lombok-api.jar, which then causes another problem regarding some AccessLevel annotation at runtime dex.

This suggests that it includes the lombok jar file in apk. This should not be, any suggestions?

+7
source share
1 answer

You cannot use sourceSets because we use custom ones. You will need to do the following:

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

However, it should be possible instead to remove the dependency from our "package" configuration (which replaces the "runtime"). I will review it.

+5
source

All Articles