【发布时间】:2018-04-14 06:46:30
【问题描述】:
在问这个问题之前,我搜索了一个答案
简而言之:Android Studio 3.0.0 版的最新版 Gradle 插件出现问题。
如果我使用以前版本的 Gradle 插件 (2.3.3) Studio 构建 .apk 没有问题/
错误文字:
错误:任务执行失败 ':stockManagment:transformClassesWithStackFramesFixerForNextDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.util.concurrent.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
}
}
提前感谢您的帮助。
【问题讨论】:
-
你可以使用
exclude 'META-INF/*'你运行gradlew clean build了吗? -
是的,我做到了。它没有帮助。
标签: android-studio build.gradle