Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决;TransformException:java.util.zip.zipeException:duplicate entry;在Android中?_Android_Android Gradle Plugin_Android Build - Fatal编程技术网

如何解决;TransformException:java.util.zip.zipeException:duplicate entry;在Android中?

如何解决;TransformException:java.util.zip.zipeException:duplicate entry;在Android中?,android,android-gradle-plugin,android-build,Android,Android Gradle Plugin,Android Build,错误说明: 错误:任务的执行失败 “:app:transformClassesWithJarMergingForDebug”。> com.android.build.api.transform.TransformException: java.util.zip.ZipException:重复条目: com/google/api/client/http/AbstractInputStreamContent.class 这是我的毕业代码 apply plugin: 'com.android.appl

错误说明:

错误:任务的执行失败 “:app:transformClassesWithJarMergingForDebug”。> com.android.build.api.transform.TransformException: java.util.zip.ZipException:重复条目: com/google/api/client/http/AbstractInputStreamContent.class

这是我的毕业代码

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.richwebs.user.hohoride"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

packagingOptions{
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.google.api-client:google-api-client-android:1.20.0') {
    exclude group: 'org.apache.httpcomponents'
}

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.android.gms:play-services-base:9.0.2'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile group: 'commons-io', name: 'commons-io', version: '2.0.1'

}
android {
useLibrary 'org.apache.http.legacy'
}

解决这个问题有两种方法

  • 如果你的应用程序中的方法引用超过了它的限制,那么像这样增加heapsize
  • 德克斯选项{ preDexLibraries=false javaMaxHeapSize“4g” }

    还可以像这样启用多索引支持:

    defaultConfig {
    
            multiDexEnabled true
        }
    
    dependencies {   
        compile 'com.android.support:multidex:1.0.1'
    }
    
    并在清单文件中设置名称属性:

    <application
            android:name="android.support.multidex.MultiDexApplication" >
    </application>
    

    我对这三个模块有一个问题,所以o只是从所有依赖项中排除,我的错误消失了

    导入的libs的不同版本可能存在问题

    你有

      compile 'com.google.android.gms:play-services-analytics:9.0.0' // wrong!
      compile 'com.google.android.gms:play-services-gcm:9.0.2'
    
    确保始终使用相同的版本,如:

      compile 'com.google.android.gms:play-services-analytics:9.0.2'
      compile 'com.google.android.gms:play-services-gcm:9.0.2'
    

    首先告诉我你应用了dexConfig吗?不,我没有使用dexConfig,否则就把整个gradle.build代码。。所以我可以建议你必须实现的是的,我编辑我的代码,plz helpbcz,你只从一个库中排除。你应该像我一样从所有lib中排除。不要只通过小组。同样,bcz当我遇到这个问题时,我参考了stackoverflow的很多链接。这是我找到的最好的解决方案。方法2是什么?还有,这个问题变了吗?多重索引在这里要做什么?
      compile 'com.google.android.gms:play-services-analytics:9.0.2'
      compile 'com.google.android.gms:play-services-gcm:9.0.2'