martin treurnicht
martin treurnicht

Reputation: 1253

Gradle Configurations not Working as Expected in New Android Build System

Environment Configuration

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?

Upvotes: 8

Views: 2151

Answers (1)

Xavier Ducrohet
Xavier Ducrohet

Reputation: 28539

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.

Upvotes: 6

Related Questions