android studio不会编译改造

时间:2016-04-13 09:49:51

标签: android android-studio gradle retrofit retrofit2

我生成了一个应用程序的签名apk我几天前工作(bea版本)。 我现在正在尝试编译项目的改造,同步阶段工作正常,但当我尝试运行应用程序时,我收到此错误:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 
'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' 
finished with non-zero exit value 2

我尝试在新项目上编译Retrofit并且编译完成。

以下是依赖项(我试图单独评论简单的xml,也没有帮助):

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile files('libs/UniversalImageLoader195.jar')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    //compile 'com.squareup.retrofit2:retrofit:2.0.1'
    //compile 'com.squareup.retrofit2:converter-simplexml:2.0.0-beta3'
}

有什么想法吗?

2 个答案:

答案 0 :(得分:2)

尝试使用一些较新版本的改造:

    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'

答案 1 :(得分:1)

搜索后,更新Android Studio并进行了大量尝试: multidexEnabled true - >除了某些部分外,没有任何帮助。 我真正需要的是:

  1. 删除此内容:

    compile 'com.loopj.android:android-async-http:1.4.9'"
    
  2. (或者它正在使用一些已经由另一个库编译的软件包,或者它可能使应用程序超过64k的限制,无论哪种方式,它都是可有可无的,因为Retrofit会给你OkHttp内置)。

    2.将简单的xml更改为以下内容:

    compile ('com.squareup.retrofit2:converter-simplexml:2.0.1') {
            exclude group: 'xpp3', module: 'xpp3'
            exclude group: 'stax', module: 'stax-api'
            exclude group: 'stax', module: 'stax'
    }
    

    我不确定" stax"但是" xpp3"肯定会出现错误。我在另一篇文章中找到了这个答案。

    我希望它也可以帮助别人。