2016-08-16 144 views
0

我正在研究Android項目,嘗試製作簽名APK。我沒有在代碼或任何缺少的庫中發現任何錯誤,我的項目也運行良好。但是當我嘗試使用SIGNED APK時,出現以下錯誤:

duplicate entry: com/google/gson/Gson$5.class 

我的Gradle如下所示。我遵循這個論壇的不同答案,但仍然遇到問題。

apply plugin: 'com.android.application' 


dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.github.bumptech.glide:glide:3.6.1' 
    compile 'com.android.support:support-v4:23.1.0' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.github.bumptech.glide:glide:3.6.1' 
    compile 'org.apache.commons:commons-collections4:4.0' 

    //compile 'com.google.android.gms:play-services:4.0.30' 

    compile 'com.google.android.gms:play-services-maps:8.4.0' 

    compile 'jp.wasabeef:glide-transformations:2.0.0' 
    // If you want to use the GPU Filters 
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0' 


    //compile files('libs/google-play-services.jar') 
// compile project(':uImageLoader') 
    //compile files('libs/android-support-v4.jar') 

    compile 'cn.trinea.android.common:trinea-android-common:4.2.15' 

    // IO Library used for Files 
    compile ('com.octo.android.robospice:robospice-retrofit:1.4.13') { 
     exclude group: 'org.apache.commons', module: 'commons-io' 
    } 
    compile 'commons-io:commons-io:1.3.2' 


    compile project(':ParseUI-Login') 
    compile rootProject.ext.androidSupport 
    compile rootProject.ext.parse 

} 

buildscript { 
    repositories { 
     jcenter() 
    } 
    repositories 
    dependencies { 
     // TODO: move this to a stable release as soon as one becomes available 
     classpath 'com.android.tools.build:gradle:2.1.0' 
    } 
} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.fourbong" 
     minSdkVersion 19 
     targetSdkVersion 20 
     versionCode 4 
     versionName "1.0" 
     multiDexEnabled true 
     // android.enforceUniquePackageName=false 
    } 


     packagingOptions { 
      exclude 'META-INF/LICENSE.txt' 
      exclude 'META-INF/NOTICE.txt' 
      exclude 'META-INF/maven/commons-io/commons-io/pom.xml' 
      exclude 'META-INF/maven/commons-io/commons-io/pom.properties' 
     } 


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

configurations { 
    all*.exclude group: 'com.android.support', module: 'support-v4' 
} 
+0

爲什麼你爲編譯「COM .github.bumptech.glide:glide:3.6.1'這兩次? –

+0

@Dipalishah錯誤我寫在那裏,我刪除它。但是我仍然對複製gson有同樣的問題。 –

+0

無關但仍然錯誤:刪除support-v4。 a)版本與appcompat-v7不匹配。 b)Appcompat-v7依賴於support-v4,因此無論如何它都包含在內。 c)爲什麼最後排除支持庫?當您最終設法運行它時,該應用程序會崩潰。 –

回答

0

添加

compile 'com.github.bumptech.glide:glide:3.6.1' 
compile 'com.android.support:support-v4:23.1.0' 
compile 'com.android.support:multidex:1.0.0' 
compile 'com.github.bumptech.glide:glide:3.6.1' 
compile 'org.apache.commons:commons-collections4:4.0' 

編譯 'com.github.bumptech.glide:滑翔:3.6.1' 這兩次刪除任何一個和改造項目

+0

如果你兩次添加完全相同的東西,它不起作用。除了我非常懷疑滑翔取決於gson。 –

+0

@EugenPechanec,它不依賴於任何GSON – Kushan