无法构建发布apk版

问题描述 投票:0回答:2

当我生成APK的发布版本时会出现问题。我已经查看了这个question并尝试所有提到但问题仍然存在请指出我正确的方向

错误

错误:任务执行失败:app:transformClassesWithJarMergingForRelease'。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android / support / design / widget / CoordinatorLayout $ 1.class

gradle这个

  apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.3"
        dexOptions {
            javaMaxHeapSize "4g"
        }
        defaultConfig {
            applicationId "com.example.wildstone.cv_maker"
            minSdkVersion 19

            versionCode 1
            versionName "1.0"
            targetSdkVersion 27

            multiDexEnabled true //important
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:27.+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.android.support:cardview-v7:26.0.0-alpha1'
        compile 'com.android.support:design:26.0.0-alpha1'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.google.android.gms:play-services:7.5.0'
        compile 'com.itextpdf:itextg:5.5.10'
        testCompile 'junit:junit:4.12'
    }
java android gradle proguard android-proguard
2个回答
2
投票

当您使用不同版本的SDK和支持库时,通常会发生这种情况。替换这些版本

compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'

compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'

它应该工作。


0
投票

当你使用时,你的sdk版本是27 编译'com.android.support:cardview-v7:26.0.0-alpha1'compile'c​​om.android.support:design:26.0.0-alpha1'

用27的替换你的26

© www.soinside.com 2019 - 2024. All rights reserved.