Android的工作室升级到1.0腐败MultiDex [英] Android Studio update to 1.0 corrupts MultiDex

查看:353
本文介绍了Android的工作室升级到1.0腐败MultiDex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在0.9.3和我更新到1.0后,曾多DEX工作正常,我有这样的错误:

 错误:未能执行任务:应用程序:packageAllDebugClassesForMultiDex。
> java.util.zip.ZipException:重复项:组织/阿帕奇/公/ IO / CopyUtils.class
 

有什么奇怪的是,我并没有改变任何东西,添加任何相关性或库。它只是不工作。我试着更新multidex至1.0.1版本,但仍然没有运气

我应该如何去解决这个问题?

[更新](minSDK是14和目标SDK是21) 当我建立与目标分21 SDK它没有错误。 构建文件以下

 应用插件:com.android.application

安卓{

    productFlavors {
        //定义独立的开发和督促产品的味道。
        开发{
            //开发利用的minSdkVersion = 21,允许Android的摇篮插件
            //为pre-DEX每个模块,并产生了可以检测在一个APK
            // Android的棒棒糖不费时DEX合并过程。
            的minSdkVersion rootProject.ext.targetSdkVersion
        }
        督促{
            //实际的minSdkVersion应用程序。
            的minSdkVersion rootProject.ext.minSdkVersion
        }
    }

    库{
        mavenCentral()
        行家{
            名称'maven.aviary.com
            URL的URI(http://maven.aviary.com/repo/release)
        }
    }


    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        的applicationIDnet.getfoodie.foodie
        的minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        版本code rootProject.ext.version code
        VERSIONNAME rootProject.ext.versionName
        multiDexEnabled真
    }
    //添加选项编译更高版本的Java实现多catch错误,例如
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    buildTypes {
//调试{
// runProguard真
// proguardFilesProGuard的项目,DEBUG.TXT
//}
        推出 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'proguard-rules.pro
        }
    }


    packagingOptions {
        不包括META-INF / DEPENDENCIES
        不包括META-INF /注意事项
        不包括META-INF /许可证
        不包括META-INF / LICENSE.TXT
        不包括META-INF / NOTICE.txt
    }
}

依赖{
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.facebook.android:facebook-android-sdk:3.20.0
    //编译com.google code.gson:GSON:2.3
//编译org.apache.commons:公地lang3:3.3.2
    编译net.danlew:android.joda:2.4.0
    编译com.google.maps.android:android-maps-utils:0.3.+
    编译com.squareup.picasso:毕加索:2.4.0
    编译com.aviary.android.feather.sdk:舍-SDK:3.4.3.351
    编译com.pkmmte.view:circularimageview:1.1



    编译com.android.support:multidex:1.0.+

    //谷歌播放服务
    编译com.google.android.gms:播放服务:87年6月5日
    //支持库
    编译com.android.support:appcompat-v7:21.0.3
    编译com.android.support:cardview-v7:21.0.0
    编译com.android.support:gridlayout-v7:21.0.0
//编译com.android.support:mediarouter-v7:21.0.0
//编译com.android.support:palette-v7:21.0.0
    编译com.android.support:recyclerview-v7:21.0.0
    编译com.android.support:support-annotations:21.0.0
    编译com.android.support:support-v13:21.0.0

    编译com.android.support:support-v4:21.0.3
    编制项目(:ParseLoginUI)
}
 

解决方案

我可以只是包括鸟舍-SDK库重现这一个测试项目。我并不需要多DEX,我没有调查不同的SDK版本,这似乎有点神秘的对我。

如果你没有多DEX,你得到经典的多个DEX文件定义...的错误,这意味着你已经包含了相同的符号不止一次在你的构建,这你不能做的。

这些问题可以采取侦探一点点;这也正是摇篮依赖任务,可以非常方便。如果你进入你的模块的目录(不是顶级目录),然后运行该任务:

  ../ gradlew依赖
 

您可以:

 编译 - 类路径编制的主要来源。
+ --- com.aviary.android.feather.sdk:舍-SDK:3.4.3.351
| \ --- com.aviary.android.feather.sdk:SDK库:3.5.1
| + --- it.sephiroth.android.library.hlistviewanimations:hlistviewanimations库:1.0.1
| | + --- it.sephiroth.android.library.horizo​​ntallistview:hlistview:1.2.2
| | | \ --- com.android.support:support-v4:19.1.+  - > 21.0.3
| | | \ --- com.android.support:support-annotations:21.0.3
| | \ --- com.nineoldandroids:库:2.4.0
| + --- com.nineoldandroids:库:2.4.0
| + --- it.sephiroth.android.library.disklruimagecache:DiskLruImageCache:1.0.2
| | + --- org.apache.commons:公共-IO:1.3.2
| | \ --- com.jakewharton:disklrucache:2.0.2
| + --- com.aviary.android.feather.sdk:CDS库:3.2.4
| | + --- com.aviary.android.feather.sdk:共库:3.1.2  - > 3.1.8.1
| | | + --- org.apache.commons:公地lang3:3.3.2
| | | + --- com.squareup.okhttp:okhttp-的URLConnection:1.6.0
| | | | \ --- com.squareup.okhttp:okhttp:1.6.0
| | | + --- com.squareup.okhttp:okhttp:1.6.0
| | | + --- com.intellij:注释:+  - > 12.0
| | | \ ---公共-IO:公地IO:2.4
| | \ --- com.android.support:support-v4:19.+  - > 21.0.3(*)
| + --- it.sephiroth.android.library.disklrumulticache:disklrumulticache:1.0.2
| | + --- org.apache.commons:公共-IO:1.3.2
| | \ --- com.jakewharton:disklrucache:2.0.2
| + --- it.sephiroth.android.library.picasso:毕加索:2.3.3.2
| | + --- com.squareup.okhttp:okhttp-的URLConnection:1.6.0(*)
| | + --- com.squareup.okhttp:okhttp:1.6.0
| | \ --- com.intellij:注解:12.0
| + --- com.android.support:support-v4:19.+  - > 21.0.3(*)
| + --- it.sephiroth.android.exif:Android的EXIF扩展:1.0.2
| | + --- org.apache.commons:公地lang3:3.3.2
| | \ --- org.apache.commons:公共-IO:1.3.2
| + --- it.sephiroth.android.library.imagezoom:imagezoom:1.0.5
| | \ --- it.sephiroth.android.library.easing:Android的宽松:1.0.3
| + --- com.aviary.android.feather.sdk:收货库:2.0.2
| | + --- com.aviary.android.feather.sdk:共库:3.1.2  - > 3.1.8.1(*)
| | + --- it.sephiroth.android.library.ab:AB测试:2.0.3
| | \ --- com.android.support:support-v4:19.+  - > 21.0.3(*)
| + --- com.aviary.android.feather.sdk:共库:3.1.2  - > 3.1.8.1(*)
| + --- it.sephiroth.android.library.horizo​​ntallistview:hlistview:1.2.2(*)
| + --- it.sephiroth.android.library.fork.listviewanimations:listviewanimations库核心:2.6.1
| | \ --- com.nineoldandroids:库:2.4.0
| + --- com.aviary.android.feather.sdk:跟踪库:3.0.1
| | \ --- com.aviary.android.feather.sdk:共库:3.1.8.1(*)
| \ --- com.aviary.android.feather.sdk:无头库:3.4.002000000
| \ --- com.aviary.android.feather.sdk:共库:3.1.2  - > 3.1.8.1(*)
 

如果你仔细看,你会看到两个:

  

公地IO:公地IO:2.4

  

org.apache.commons:公共-io的:1.3.2

在那里,我没有确认,但我相信是同一类,其中包括组织/阿帕奇/公/ IO / CopyUtils.class 不同的包装。

如果您排除公地IO 通过:

 编译('com.aviary.android.feather.sdk:舍-SDK:3.4.3.351'){
    排除组:公地-IO
}
 

,将建造。我还没有尝试运行它,所以我不知道是否会有遗漏的符号在运行时;如果有,你可以尝试将你从依赖排除什么,或者你可以重新打包的依赖,以修复错误,或联系作者更多的手术。

I had multi dex working fine in 0.9.3 and after my update to 1.0 I have this error:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class

What's odd is that I didn't change anything, add any dependencies or library. It's just not working. I tried updating multidex to 1.0.1 but still not luck

How should I go about solving this error?

[Update] (minSDK is 14 and target SDK is 21) When I build with a target min SDK of 21 it doesn't have the bug. Build file below

apply plugin: 'com.android.application'

android {

    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion rootProject.ext.targetSdkVersion
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion rootProject.ext.minSdkVersion
        }
    }

    repositories {
        mavenCentral()
        maven {
            name 'maven.aviary.com'
            url uri("http://maven.aviary.com/repo/release")
        }
    }


    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "net.getfoodie.foodie"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        multiDexEnabled true
    }
    // Add options to compile higher versions of Java to implement multi-catch error for example
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    buildTypes {
//        debug {
//            runProguard true
//            proguardFiles 'proguard-project-debug.txt'
//        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.facebook.android:facebook-android-sdk:3.20.0'
    //    compile 'com.google.code.gson:gson:2.3'
//    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'net.danlew:android.joda:2.4.0'
    compile 'com.google.maps.android:android-maps-utils:0.3.+'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.aviary.android.feather.sdk:aviary-sdk:3.4.3.351'
    compile 'com.pkmmte.view:circularimageview:1.1'



    compile 'com.android.support:multidex:1.0.+'

    // Google Play Services
    compile 'com.google.android.gms:play-services:6.5.87'
    // Support Libraries
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:cardview-v7:21.0.0'
    compile 'com.android.support:gridlayout-v7:21.0.0'
//    compile 'com.android.support:mediarouter-v7:21.0.0'
//    compile 'com.android.support:palette-v7:21.0.0'
    compile 'com.android.support:recyclerview-v7:21.0.0'
    compile 'com.android.support:support-annotations:21.0.0'
    compile 'com.android.support:support-v13:21.0.0'

    compile 'com.android.support:support-v4:21.0.3'
    compile project(':ParseLoginUI')
}

解决方案

I was able to reproduce this in a test project just by including the aviary-sdk library. I didn't need multi-dex, and I didn't investigate different SDK versions, which seems a little mysterious to me.

If you don't have multi-dex, you get the classic "multiple dex files define..." error which means you've included the same symbol more than once in your build, which you're not allowed to do.

These problems can take a little bit of sleuthing; that's where the gradle dependencies task can be very handy. If you go into your module's directory (not the top-level directory) and run this task:

../gradlew dependencies

you get:

compile - Classpath for compiling the main sources.
+--- com.aviary.android.feather.sdk:aviary-sdk:3.4.3.351
|    \--- com.aviary.android.feather.sdk:sdk-library:3.5.1
|         +--- it.sephiroth.android.library.hlistviewanimations:hlistviewanimations-library:1.0.1
|         |    +--- it.sephiroth.android.library.horizontallistview:hlistview:1.2.2
|         |    |    \--- com.android.support:support-v4:19.1.+ -> 21.0.3
|         |    |         \--- com.android.support:support-annotations:21.0.3
|         |    \--- com.nineoldandroids:library:2.4.0
|         +--- com.nineoldandroids:library:2.4.0
|         +--- it.sephiroth.android.library.disklruimagecache:DiskLruImageCache:1.0.2
|         |    +--- org.apache.commons:commons-io:1.3.2
|         |    \--- com.jakewharton:disklrucache:2.0.2
|         +--- com.aviary.android.feather.sdk:cds-library:3.2.4
|         |    +--- com.aviary.android.feather.sdk:common-library:3.1.2 -> 3.1.8.1
|         |    |    +--- org.apache.commons:commons-lang3:3.3.2
|         |    |    +--- com.squareup.okhttp:okhttp-urlconnection:1.6.0
|         |    |    |    \--- com.squareup.okhttp:okhttp:1.6.0
|         |    |    +--- com.squareup.okhttp:okhttp:1.6.0
|         |    |    +--- com.intellij:annotations:+ -> 12.0
|         |    |    \--- commons-io:commons-io:2.4
|         |    \--- com.android.support:support-v4:19.+ -> 21.0.3 (*)
|         +--- it.sephiroth.android.library.disklrumulticache:disklrumulticache:1.0.2
|         |    +--- org.apache.commons:commons-io:1.3.2
|         |    \--- com.jakewharton:disklrucache:2.0.2
|         +--- it.sephiroth.android.library.picasso:picasso:2.3.3.2
|         |    +--- com.squareup.okhttp:okhttp-urlconnection:1.6.0 (*)
|         |    +--- com.squareup.okhttp:okhttp:1.6.0
|         |    \--- com.intellij:annotations:12.0
|         +--- com.android.support:support-v4:19.+ -> 21.0.3 (*)
|         +--- it.sephiroth.android.exif:android-exif-extended:1.0.2
|         |    +--- org.apache.commons:commons-lang3:3.3.2
|         |    \--- org.apache.commons:commons-io:1.3.2
|         +--- it.sephiroth.android.library.imagezoom:imagezoom:1.0.5
|         |    \--- it.sephiroth.android.library.easing:android-easing:1.0.3
|         +--- com.aviary.android.feather.sdk:receipt-library:2.0.2
|         |    +--- com.aviary.android.feather.sdk:common-library:3.1.2 -> 3.1.8.1 (*)
|         |    +--- it.sephiroth.android.library.ab:ab-test:2.0.3
|         |    \--- com.android.support:support-v4:19.+ -> 21.0.3 (*)
|         +--- com.aviary.android.feather.sdk:common-library:3.1.2 -> 3.1.8.1 (*)
|         +--- it.sephiroth.android.library.horizontallistview:hlistview:1.2.2 (*)
|         +--- it.sephiroth.android.library.fork.listviewanimations:listviewanimations-library-core:2.6.1
|         |    \--- com.nineoldandroids:library:2.4.0
|         +--- com.aviary.android.feather.sdk:tracking-library:3.0.1
|         |    \--- com.aviary.android.feather.sdk:common-library:3.1.8.1 (*)
|         \--- com.aviary.android.feather.sdk:headless-library:3.4.002000000
|              \--- com.aviary.android.feather.sdk:common-library:3.1.2 -> 3.1.8.1 (*)

If you look carefully, you'll see both:

commons-io:commons-io:2.4

and

org.apache.commons:commons-io:1.3.2

in there, which I didn't confirm, but I assume are different packagings of the same classes which include org/apache/commons/io/CopyUtils.class.

If you exclude commons-io via:

compile ('com.aviary.android.feather.sdk:aviary-sdk:3.4.3.351') {
    exclude group: 'commons-io'
}

it will build. I haven't tried to run it, so I don't know if there will be missing symbols at runtime; if there are, you could try to be more surgical about what you exclude from the dependency, or perhaps you could repackage the dependency to fix the errors, or contact its author.

这篇关于Android的工作室升级到1.0腐败MultiDex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆