【问题标题】:Transform Exception thrown even when multidexEnabled即使 multidexEnabled 也会抛出转换异常
【发布时间】:2016-08-25 23:48:05
【问题描述】:

我正在尝试在 Android Studio 中构建我的应用的发布版本,但无论我尝试什么,我都会收到错误消息:

任务执行失败 '应用程序:transformClassesWithJarMergingForRelease'。 > com.android.build.api.transform.TransformException: java.util.zip.ZipException:重复条目: com/android/volley/Request$Priority.class.

我启用了 multidex,清理并重建了我的应用程序,但没有任何效果。 以下是我的 gradle 构建:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "carter.streakly"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.google.android.gms:play-services-appindexing:8.1.0'
    compile 'com.google.android.gms:play-services:9.2.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'org.jetbrains:annotations-java5:15.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.android.support:multidex:1.0.0'
}

【问题讨论】:

标签: java android exception android-gradle-plugin android-volley


【解决方案1】:

build.gradle 依赖项中包含两个库:

compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.volley:volley:1.0.0'

wherecom.mcxiaoke.volley 基本上是谷歌官方库的一个分支,所以你应该只使用其中一个。另请注意,根据mcxiaoke/android-volley READ.ME

(...) 此项目已弃用,不再维护,请使用 jCenter 的官方版本。

compile 'com.android.volley:volley:1.0.0'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-20
    • 2021-06-19
    • 2022-06-15
    • 2015-07-10
    • 2019-11-11
    • 2011-07-24
    • 1970-01-01
    相关资源
    最近更新 更多