Android: Error: Execution failed for task app: transformClassesWithPreJackPackagedLibrariesForDebug

I got this error when I tried to run my android program.

Error: Execution completed for task ': app: transformClassesWithPreJackPackagedLibrariesForDebug'. java.lang.AssertionError: java.util.zip.ZipException: duplicate entry: jayce / org / hamcrest / BaseDescription.jayce

here is my build.gradle

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    applicationId "com.surgical.decision"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    jackOptions {
        enabled true
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile files('libs/simple-xml-2.7.1.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/pddl4j-3.5.0.jar')
}

      

I need to enable jackOptions because there are many features that I wrote in Java 8.

+3


source to share


1 answer


I had the same problem. I believe it is com.android.support.test.espresso:espresso-core:2.2.2

compiled with hamcrest and I think it is com.android.support:appcompat-v7:25.3.1

also compiled with hamcrest. I believe the error message tells you that the hamcrest package is contained in at least two compiled jars and it cannot fix the duplicate problem (even if it is the same version). He probably can't solve the duplicate due to Jack's technicality. To work around the problem, you just need to exclude it from one or the other:

ie

`androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'org.hamcrest', module: 'hamcrest-core'

})

      

or if you are not using espresso core just remove the androidTestCompile line.

In my situation, I also had to add:



exclude group: 'junit', module: 'junit'

      

because I was getting a slightly different error due to the inclusion of two different junit version conflicts.

The best way to debug these errors is to use gradle from the command line.

  • open command prompt
  • go to the project directory (it contains gradlew.bat)
  • gradlew app: androidDependencies

0


source







All Articles