生成签名apk时出现重复输入错误

时间:2018-03-13 10:26:00

标签: android

在android中构建签名的apk时出现此错误。请帮我解决这个问题。

错误是:

  

错误:任务执行失败':app:transformClassesWithJarMergingForRelease'。

     

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android / support / compat / R $ bool.class

build.gradle app 级别:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26

    defaultConfig {
        applicationId "com.glocar.dealers"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 3
        multiDexEnabled true
        versionName "1.1.1"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
    }

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


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.0.0'
    compile 'com.android.support:support-v4:26.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    implementation 'com.android.support:support-vector-drawable:26.0.0'
    implementation 'com.roughike:bottom-bar:2.3.1'
    compile 'com.github.bumptech.glide:glide:4.1.0'
    compile 'com.android.support:recyclerview-v7:26.0.0'
    compile 'com.android.support:cardview-v7:26.0.0'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.makeramen:roundedimageview:2.3.0'
    // retrofit, gson
    compile 'com.google.code.gson:gson:2.6.2'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'


    //firebase
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-crash:11.8.0'
  //  compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.google.android.gms:play-services:11.8.0'
    compile 'com.android.volley:volley:1.1.0'
    compile 'com.android.support:design:26.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.0'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.0'
            }
        }
    }
}
apply plugin: 'com.google.gms.google-services'

项目级别的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.0.0'

        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }



    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

4 个答案:

答案 0 :(得分:1)

尝试删除此行:

implementation 'com.roughike:bottom-bar:2.3.1'

尝试使用支持库中的BottomNavigationView而不是此库

答案 1 :(得分:1)

问题可能是由于以下依赖关系:

implementation 'com.roughike:bottom-bar:2.3.1'

如果您检查其project build.gradlemodule build.gradle,您会发现它仍然使用25.3.0支持库版本com.android.support:appcompat-v7com.android.support:design

因此,您需要将以下两个支持库排除在外:

implementation ("com.roughike:bottom-bar:2.3.1") {
    exclude group: 'com.android.support'
    exclude module: 'appcompat-v7'
    exclude module: 'design'
}

请注意,不推荐使用底栏库。

答案 2 :(得分:1)

将版本[26.0.0]更新为某个新版本,所有支持依赖项必须具有相同的版本,然后清理项目并再次运行

答案 3 :(得分:1)

通过使用更新版本更新每个库,我摆脱了这个问题。 之前我使用google捆绑的库+ google seprate库进行登录,这会产生重复。所以我删除了捆绑的库并使用seprate库进行谷歌登录,然后清理项目 就是这样。