android - Android Studio 1.5中的Gradle Build Run错误(DebugUtils.class)

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

我收到以下错误

错误:任务执行失败

:app:transformClassesWithJarMergingForDebug. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/DebugUtils.class



我整天都在搜索,但找不到能解决我问题的正确答案。

我的应用程序buldle 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'
}

我尝试了“清理并重建”,但是那也行不通。
请帮忙。提前致谢。

最佳答案

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

在您的项目中,您要添加很多次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'
    }
    

    关于android - Android Studio 1.5中的Gradle Build Run错误(DebugUtils.class),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36823400/

    相关文章:

    gradle - grails 3 cobertura没有显示线覆盖率

    android - 如何将 Javadoc 集成到 Xamarin Java 绑定(bind)库中?

    android - Android 上的 AWS Cognito - 如何从刷新 token 获取新 session

    Android:如何让软键盘根本不出现

    android - 如何控制android中的ontouch功能?

    xcode - 无法在XCode中使用Cocoapods存档Kotlin Native

    android - appcompat-v7 :27. 1.1 与播放服务 :11. 0.1 冲突

    grails - Grails 3 set-version替换

    android - 在Android Studio中Gradle构建失败

    android - 如何使用 android studio 将 TIKA 添加到 build.gradle 中?