重复条目:META-INF/当build.apk.与gradle插件3.0.0.排除不适用于此处



在问这个问题之前,我搜索了一个答案

简而言之:适用于Android Studio 3.0.0版本的Gradle插件的最新版本出现了问题。

如果我使用以前版本的Gradle插件(2.3.3)Studio builds.apk没有问题/

错误文本:

错误:任务执行失败":stockManagment:transformClassesWithStackFramesFixerForNextDebug"。

com.android.build.api.transform.TransformException:java.lang.RuntimeException:java.lang.RuntimeException:java.util.courrent.ExecutionException:java.util.courrent.ExecutionException:com.android.builder.utils.FileCache$FileCreatorException:java.util.zip.ZipException:重复条目:META-INF/

在SO和其他网站上找到的所有解决方案都建议使用"exclude",但这些问题通常出现在"META-INF/somefile.txt"目录中,而不是"META-INF/"目录本身。

我不能排除整个"META-INF/"目录,但我排除了该目录中的常见文件(许可证、依赖项等)

这是我的build.gradle文件。

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.3'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
signingConfigs {
release_config {
keyAlias 'stock_managment'
keyPassword '********'
storeFile file('../stockmanagment_keystore.jks')
storePassword '********'
}
}
defaultConfig {
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
multiDexKeepProguard file('multidex-config.pro')
signingConfig signingConfigs.release_config
}
debug {
}
}
flavorDimensions "next"
productFlavors {
next {
applicationId "com.stockmanagment.next.app"
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
versionCode 47
versionName '2.0.17'
dimension "next"
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
lintOptions {
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LGPL2.1'
}
}
def support = '26.1.0'
def dagger = '2.11'
def butterKnife = "8.8.1"
def moxy = "1.5.3"
def robolectric = "3.0"
dependencies {
implementation fileTree(include: ['*.jar'], dir: '../libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true
}
implementation "com.google.dagger:dagger:$dagger"
implementation("com.android.support:recyclerview-v7:$support") {
exclude group: 'com.android.support', module: 'cardview-v7'
}
implementation("com.android.support:design:$support") {
exclude group: 'com.android.support', module: 'cardview-v7'
}
implementation("com.android.support:appcompat-v7:$support") {
exclude group: 'com.android.support', module: 'cardview-v7'
}
implementation("com.android.support:preference-v7:$support") {
exclude group: 'com.android.support', module: 'cardview-v7'
}
implementation "com.jakewharton:butterknife:$butterKnife"
implementation("com.android.support:support-v4:$support") {
exclude group: 'com.android.support', module: 'cardview-v7'
}
annotationProcessor "com.google.dagger:dagger-compiler:$dagger"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnife"
implementation "com.arello-mobile:moxy:$moxy"
implementation "com.arello-mobile:moxy-app-compat:$moxy"
testImplementation "org.robolectric:robolectric:$robolectric"
testImplementation "org.robolectric:shadows-multidex:$robolectric"
annotationProcessor "com.arello-mobile:moxy-compiler:$moxy"
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'petrov.kristiyan.colorpicker:colorpicker-library:1.1.2'
implementation 'com.borax12.materialdaterangepicker:library:1.9'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
implementation 'com.nikhilpanju.recyclerviewenhanced:recyclerviewenhanced:1.1.0'
implementation 'com.github.johnkil.print:print:1.3.1'
implementation 'com.github.ybq:Android-SpinKit:1.1.0'
implementation 'com.github.tiromansev:Android-Prefs-Wrapper:0.2.2'
implementation 'org.solovyev.android:checkout:1.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'org.mockito:mockito-core:2.5.0'
implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
implementation 'com.github.tiromansev:Android-Permission-Manager:0.2.7'
implementation 'com.itextpdf:itextpdf:5.5.12'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
implementation 'com.github.tiromansev:Android-File-Dialog:0.2.4'
implementation 'com.github.tiromansev:Android-Scan-Barcode:0.3.0'
implementation 'com.github.tiromansev:FloatingActionButton:1.6.7'
implementation 'com.github.tiromansev:AndroidTreeView:0.0.1'
}
task copyLocales << {
copy {
from 'src/main/res/values-ru/strings.xml'
into 'src/main/res/values-uk'
}
copy {
from 'src/main/res/values-ru/strings.xml'
into 'src/main/res/values-be'
}
copy {
from 'src/main/res/values/strings.xml'
into 'src/main/res/values-en'
}
}
preBuild.dependsOn copyLocales
tasks.whenTaskAdded { task ->
if (task.name == "lint") {
task.enabled = false
}
}

提前感谢您的帮助。

问题出在Apache POI库上,该库以.jar文件的形式包含在/libs目录中。这个.jar包含空的/META-INF目录,这就是问题的原因。

从.jar文件中删除这个空目录解决了问题。如果/META-INF不为空,它也可以正常工作。使用Gradle插件2.3.3 building.apk,即使在/META_INF目录为空的情况下也能顺利工作。

因此,Gradle插件3.0.0和.jar中空的/META_INF目录的组合造成了问题。

2017年11月27日更新此错误已在当前版本中修复

最新更新