android - 任务 ':MyApp:dexDebug' 执行失败

标签 android compiler-errors dex

我最近从 Eclipse 切换到 Android Studio,但在编译我的应用程序时遇到了问题。我已经处理了很多问题并且能够解决所有问题,除了一个:

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

我读到这可能意味着您有重复的 jar,所以我检查了我的 gradle 配置,但它看起来不错。我什至经历过并评论了一对一(以及多对一/一对多)的编译,但无济于事。这是我的 gradle 配置:

dependencies {
    compile project(':comcrashlyticssdkandroid_crashlytics_2')
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/gcm.jar');
}

我最好的猜测是 libs/gcm.jar,因为 gcm 已“弃用”到 google play 服务。但是,没有 gcm 可以进行服务迁移,所以我现在只能使用 gcm。

另一个仅供引用,我在 Eclipse 中遇到了 dex 编译问题,但我会从项目中删除“私有(private)库”,一切都很好。 Android Studio 中是否有与此等效的东西?

我最大的问题是您建议我接下来尝试什么来解决这个问题?

最佳答案

你有:

dependencies {
    compile project(':comcrashlyticssdkandroid_crashlytics_2')
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/gcm.jar');
}

尝试:

dependencies {
    compile project(':comcrashlyticssdkandroid_crashlytics_2')
    compile 'com.android.support:support-v4:22.2.1' // updated
    compile 'com.google.android.gms:play-services-analytics:7.5.0' // updated
    compile 'com.google.android.gms:play-services-gcm:7.5.0' // updated
}

并遵循更新后的指南:https://developers.google.com/cloud-messaging/android/client

对于 crashlytics,使用他们的配置:http://docs.fabric.io/android/crashlytics/build-tools.html#gradle-advanced-setup

文档: https://developers.google.com/android/guides/setup

关于android - 任务 ':MyApp:dexDebug' 执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31815243/

相关文章:

c# - 从 wcf ksoap2 接收字节 [] 到 android 时遇到问题

c++ - 使用 map<string,struct> 类型的映射编译头文件时出错

android - eclipse ,安卓 : Unexpected Unable to execute dex: Multiple dex files define

Android 从通话记录中提取通话时间

java - 在 Java 中合并 2 个 HashMap

android - ionic 运行 android - 错误 : Cannot find module 'internal/fs' - windows

compiler-errors - java中未定义的错误

c++ - SFINAE 不能防止不明确的运算符重载吗?

android - Urban-airship + Facebook cordova 插件 android-support-v4 冲突

android - 现在无法访问dex任务,如何升级到1.5.0?