2016-08-16 145 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