【问题标题】:Unable to generate signed apk in Android Studio, getting error无法在 Android Studio 中生成签名的 apk,出现错误
【发布时间】:2016-09-11 22:05:59
【问题描述】:

我正在 android studio 中生成一个签名的 apk,但出现以下错误:

错误:任务“:msapp_V_520:transformClassesWithJarMergingForRelease”执行失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/annotation/ColorRes.class

这是我的 build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


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

    compileSdkVersion 23
    buildToolsVersion '23.0.3'
    defaultConfig {
        applicationId "com.mouthshut"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true
        useLibrary 'org.apache.http.legacy'
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

dependencies {

    compile project(':comnostra13exampleuniversalimageloaderHomeActivity')
    compile project(':nineoldandroid')
    compile project(':libraryActionbar')
    compile project(':pullToRefresh')
    compile project(':facebook')
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:multidex:1.0.+'
    compile files('libs/AF-Android-SDK-v2.3.1.19.jar')
    compile files('libs/classes.jar')
    compile files('libs/CleverTapAndroidSDK-v1-20150903.jar')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    //compile 'com.github.adrian110288:LoadIndicators:83ce610325'
    compile project(':LoadIndicatorLibrary')
    compile 'com.nispok:snackbar:2.11.+'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
    compile 'com.android.support:appcompat-v7:23.3.0'
}

【问题讨论】:

  • 你的 gradle 依赖有问题。请检查一下。
  • @MadhukarHebbar 请查看我编辑的问题它包括我的 build.gradle 文件,请就问题提出建议。
  • Facebook SDK 可能与支持库发生冲突。Chek herehere。它可能会帮助你。
  • @MadhukarHebbar 我尝试了您的解决方案,但它不起作用。

标签: java android android-studio build.gradle android-proguard


【解决方案1】:

在添加facebook 依赖时排除support-v4 模块。

compile (project(':facebook')) {
    exclude module: 'support-v4'
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-11
    • 2016-09-07
    • 1970-01-01
    • 2018-05-04
    相关资源
    最近更新 更多