【问题标题】:Gradle Build Run error (DebugUtils.class) in Android Studio 1.5Android Studio 1.5 中的 Gradle 构建运行错误 (DebugUtils.class)
【发布时间】:2016-04-24 12:57:17
【问题描述】:

我收到以下错误

错误:任务执行失败

:app:transformClassesWithJarMergingForDebug。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/util/DebugUtils.class

我搜索了一整天,但找不到可以解决我的问题的正确答案。

我的应用程序构建 gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.project.test"
    multiDexEnabled true
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

dexOptions {
    javaMaxHeapSize "4g"
}

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

// 依赖文件

dependencies 
{ 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.google.android.gms:play-services-ads:+' 
    compile 'com.google.android.gms:play-services-identity:+' 
    compile 'com.google.android.gms:play-services-gcm:+' 
    compile files('libs/android-support-v4.jar') 
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
}

我尝试了清理和重建,但这也不起作用。 请帮助解决这个问题。提前致谢。

【问题讨论】:

  • 您是否尝试过从依赖项中删除 compile files('libs/android-support-v4.jar') 行?似乎它已作为依赖项添加到 fileTree 行中。
  • 是的,阿德里安也试过了。不工作。

标签: android gradle build.gradle android-support-library


【解决方案1】:

当您添加两次相同的类时会发生此问题。

在您的项目中,您多次添加 support-v4 库。

  • 从 libs 文件夹中删除 android-support-v4.jar
  • 删除此行compile files('libs/android-support-v4.jar')
  • 更改库 'com.github.JakeWharton:ViewPagerIndicator:2.4.1' 的依赖项,因为它使用旧的 support-v4.jar

用途:

compile ('com.github.JakeWharton:ViewPagerIndicator:2.4.1') {
            exclude module: 'support-v4'
}

【讨论】:

    【解决方案2】:

    在做了一些研究之后,发现 com.github.JakeWharton:ViewPagerIndicator:2.4.1already importing android-support-v4.jar,从这里你的重复错误。为了修复它,我建议您进行以下更改:

    • 从 libs 文件夹中删除 android-support-v4.jar
    • 从 gradle 文件中删除行 compile files('libs/android-support-v4.jar')

    希望它能解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 2019-01-14
      • 2013-05-13
      • 2015-02-06
      • 2016-08-05
      • 2017-03-25
      相关资源
      最近更新 更多