2017-03-03 47 views
0

每當我嘗試爲該應用創建APK時,都會出現此錯誤。app:transformClassesWithJarMergingForDebug無法解析

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/text/TextUtilsCompat.class

該應用程序在android模擬器中運行,但是當我嘗試構建apk時出現此錯誤。 我不知道什麼改變

這裏是gradle這個代碼

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 23 
buildToolsVersion "25.0.2" 

defaultConfig { 
    applicationId "com.companyname.gamename" 
    minSdkVersion 11 
    targetSdkVersion 23 
    multiDexEnabled true 

    ndk { 
     moduleName "player_shared" 
    } 
} 

sourceSets { 
    main { 
     jni.srcDirs = [] 
    } 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
    } 
} 
} 

dependencies { 
compile 'com.google.android.gms:play-services:+' 
compile files('libs/dagger-1.2.2.jar') 
compile files('libs/javax.inject-1.jar') 
compile files('libs/support-v4-19.0.1.jar') 
compile files('libs/nineoldandroids-2.4.0.jar') 
} 

我tryed清理重建一個運行的prject但我仍然有同樣的問題, 我讀過它的depencdencies問題。但無法找到一個可以刪除的東西。

+0

評論'編譯文件(「庫/支撐v4-19.0.1.jar」)'和'使用播放服務:10.0.1',而不是'發揮服務:+' –

+0

重構庫可幫助您解決這個問題。這可能有助於從庫或應用程序模塊中刪除重複的類。 –

回答

1

首先,不要使用加依賴。

services:+' 

也不要編譯所有的播放服務,只有你真正需要的設置。

https://developers.google.com/android/guides/setup#split

其次,停止使用的jar文件,並去找使用Maven中央(或這些庫中的支持性文件)的正確庫,並使用其他方式,通過搖籃編譯。

你的jar文件有重疊的課程,因此你有錯誤

當你在它...

  • 匕首1被廢棄了匕首2
  • NineoldAndroids不再僅僅維持,所以最好找到一些其他方式來使用您需要的代碼
  • 您的支持庫需要與compileSdk版本相匹配