【问题标题】:Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug' when I build project错误:当我构建项目时,任务“:app:transformClassesWithMultidexlistForDebug”执行失败
【发布时间】:2018-07-24 08:02:41
【问题描述】:

我尝试构建项目并收到此错误:

错误:任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败。

java.io.IOException: Can't write [C:\Users\Igor\Documents\AndroidStudioProjects\MosaicPicture\app\build\intermediates\multi-dex\debug\componentClasses.jar](无法读取 [C :\Users\Igor.gradle\caches\transforms-1\files-1.1\recyclerview-v7-26.1.0.aar\8f92a0a82aeead91e034e3a46e1f2a6c\jars\classes.jar(;;;;;;**.class)] (重复zip 条目 [classes.jar:android/support/v7/widget/RecyclerView$ItemAnimator.class]))

分级:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "ru.snoitacilppa.mosaicpicture"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 8
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:exifinterface:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile project(':adcolony-sdk-3.1.2')
}

我试图清理和重建项目,但它没有帮助我

怎么了?

【问题讨论】:

  • 您可以尝试删除` implementation 'com.android.support:recyclerview-v7:26.1.0' 吗?因为它已经在com.android.support:appcompat-v7:26.1.0
  • @karandeepsingh java.lang.RuntimeException:无法恢复活动 {ru.snoitacilppa.mosaicpicture/ru.snoitacilppa.mosaicpicture.MainActivity}:android.view.InflateException:二进制 XML 文件行 #0:二进制XML 文件第 0 行:膨胀类 android.support.v7.widget.RecyclerView 时出错
  • 您的项目中是否也有 jar 文件?
  • @karandeepsingh 是的。我有与 Appodeal 相关的 .jar 文件

标签: android gradle


【解决方案1】:

更新的解决方案:

根据this accepted answer 和 cmets,从库中删除 recycler-view 库可以解决错误。


此错误主要发生在您在项目中包含库并且其中一些库包含与项目的其他包含库的共同依赖项时,这就是 Proguard 失败并出现 Duplicate Zip Entry Exception 的原因。

接受的答案herehere 应该可以帮助您解决错误。

【讨论】:

  • 我不明白。在我的情况下,我需要具体做什么?我尝试添加 PackagingOptions { exclude 'android/support/v7/widget/RecyclerView$ItemAnimator.class' } 但错误仍然存​​在
  • 根据更新的 gradle 函数 compile 已弃用,因此您能否将使用 compile 包含的最后三个依赖项更新为 implementation 并检查您遇到了什么错误?您可以参考this answer准确更新。
  • 您能否更新packagingOptions 并添加以下packagingOptions { exclude "META-INF/MANIFEST.MF" exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/license.txt' exclude 'META-INF/notice.txt' },让我知道您遇到了什么错误。
  • 是的,我不希望你的问题能完全解决,因为你有你说的罐子。我在集成时检查了 Appodeal 和一些错误,并遇到了这个 new accepted answer,如果这可以解决您的问题。
  • 当我从库中删除回收器视图库时,问题得到解决。谢谢!
猜你喜欢
  • 2016-01-23
  • 2018-06-09
  • 2018-08-01
  • 2018-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多