错误提示如下
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForLightningLiteDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: /home/wuxiaojun/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/3c8f6018eaa72d43b261181e801e6f8676c16ef6/jackson-databind-2.2.2.jar
File2: /home/wuxiaojun/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.2/d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b/jackson-core-2.2.2.jar
File3: /home/wuxiaojun/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.2.2/285cb9c666f0f0f3dd8a1be04e1f457eb7b15113/jackson-annotations-2.2.2.jar
解决办法如下:
在你的主项目的build.gradle工程里添加如下
packagingOptions {
exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' }
整体build.gradle如下
apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'com.getkeepsafe.dexcount' android { compileSdkVersion 24 buildToolsVersion "23.0.3" packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } defaultConfig { minSdkVersion 14 targetSdkVersion 24 versionName "4.3.3" vectorDrawables.useSupportLibrary = true } sourceSets { lightningPlus.setRoot('src/LightningPlus') lightningLite.setRoot('src/LightningLite') } buildTypes { debug { minifyEnabled false shrinkResources false proguardFiles 'proguard-project.txt' } release { minifyEnabled true shrinkResources true proguardFiles 'proguard-project.txt' } } productFlavors { lightningPlus { buildConfigField "boolean", "FULL_VERSION", "true" applicationId "acr.browser.lightning" versionCode 88 } lightningLite { buildConfigField "boolean", "FULL_VERSION", "false" applicationId "acr.browser.barebones" versionCode 90 } } lintOptions { abortOnError true } packagingOptions { exclude '.readme' } } dexcount { includeClasses = false includeFieldCount = false printAsTree = true orderByMethodCount = true verbose = false } dependencies { // support libraries // html parsing for reading mode // event bus // dependency injection apt 'com.google.dagger:dagger-compiler:2.0.2' provided 'javax.annotation:jsr250-api:1.0' // view binding // permissions // proxy support // Use the following code to update the libnetcipher submodule // git submodule foreach git reset --hard // git submodule update --remote compile project(':NetCipher:libnetcipher') compile project(':Bonsai:library') compile project(':AnimatedProgressBar:library') // memory leak analysis debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4' //releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4' compile 'com.android.support:palette-v7:24.2.0' compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:design:24.2.0' compile 'com.android.support:recyclerview-v7:24.2.0' compile 'com.android.support:support-v4:24.2.0' compile 'org.jsoup:jsoup:1.9.2' compile 'com.squareup:otto:1.3.8' compile 'com.google.dagger:dagger:2.0.2' compile 'com.jakewharton:butterknife:7.0.1' compile 'com.anthonycr.grant:permissions:1.1.2' compile 'net.i2p.android:client:0.8' compile 'com.firebase:firebase-client-android:2.3.1' }