嗨,当我编译我的项目时,下面的错误显示出来 对于':app:transformClassesWithMultidexlistForDebug'的任务执行失败。
java.io.IOException: Can't write [C:\Users\user\app\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\user\.gradle\caches\transforms-1\files-1.1\support-core-ui-25.2.0.aar\8bd3003da78946d664f3d05c69c73bfa\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager$2.class]))
>
注意我使用了此Thread
的所有答案+删除.Gradle文件夹 +添加了multiDexEnabled true
但它对我不起作用
我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "net.amiapp.candiesstory"
minSdkVersion 15
targetSdkVersion 27
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // レガシー ndk-build サポートを無効にする
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.android.gms:play-services-games:11.8.0'
implementation 'com.google.android.gms:play-services-plus:11.8.0'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
}

这里是project.gradle
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
maven { url "https://maven.google.com" }
jcenter()
maven { url "https://maven.google.com" }
}
}

答案 0 :(得分:1)
删除这些行并删除这些jar文件
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
您的compileSdk设置为27,而不是19,NineOldAndroids是一个已弃用的库多年
您还应该为javax.inject和dagger找到正确的implementation
依赖项而不是使用jar
您也可以删除这些回购,因为jcenter包含Maven Central
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://maven.google.com" }