【问题标题】:Getting Error:Execution failed for task ':app:dexDebug'出现错误:任务“:app:dexDebug”执行失败
【发布时间】:2016-01-25 08:35:48
【问题描述】:

我在 build.gradle 中使用了以下依赖项:

dependencies {
/*compile fileTree(dir: 'libs', include: ['*.jar'])*/
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.parse:parse-android:1.11.0'
compile 'com.parse.bolts:bolts-android:1.3.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile project(':intercom-sdk-base')
compile project(':intercom-sdk-gcm')
compile 'com.stripe:stripe-android:1.0.3'

}

我已经评论了compile fileTree(dir: 'libs', include: ['*.jar'])这一行

为了避免不匹配但仍然出现以下错误:

错误:任务 ':app:dexDebug' 执行失败> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:进程'命令 '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' 以非零结尾 退出值 2

【问题讨论】:

  • 你能发布完整的错误信息吗?
  • 你可以用compile 'com.parse:parse-android:1.12.0'代替1.11.0
  • 显示错误日志并发布build.gradle 总计。
  • @user5716019 好的,你设置了multiDexEnabled true。检查stackoverflow.com/questions/33313101/…
  • 是的,我现在添加了它,它现在可以工作了......谢谢

标签: android android-studio gradle error-handling


【解决方案1】:

您需要添加 multiDexEnabled true 。致谢multiDexEnabled

Android SDK 构建工具中提供的用于 Gradle 的 Android 插件 21.1 及更高版本支持将 multidex 作为构建配置的一部分。确保更新 Android SDK Build Tools 工具和 Android 之前使用 SDK Manager 支持 Repository 到最新版本 尝试为您的应用配置 multidex。

defaultConfig {
    ...
    minSdkVersion //Your Version
    targetSdkVersion //Your Version
    ...

    // Enabling multidex support.
    multiDexEnabled true
}

在你的依赖中调用它

  dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

建议

你可以使用compile 'com.parse:parse-android:1.12.0'

然后 Clean-Rebuild-Restart-Sync 你的项目。希望这会有所帮助。

【讨论】:

    【解决方案2】:

    这种情况经常发生。

    只需“清理项目”->“重建项目”,一切顺利。

    【讨论】:

      猜你喜欢
      • 2016-12-13
      • 2015-05-16
      • 2015-05-09
      • 1970-01-01
      • 2016-04-03
      • 2016-06-27
      相关资源
      最近更新 更多