从 Eclipse 导入到 Android Studio 后无法运行任务“:app:dexDebug"的执行失败 [英] After import from Eclipse to Android Studio cannot run Execution failed for task ':app:dexDebug"

查看:28
本文介绍了从 Eclipse 导入到 Android Studio 后无法运行任务“:app:dexDebug"的执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个在 Eclipse (4.4.2) ADT 中运行的 Android 项目,在 Linux (Ubuntu 14.10) 上运行.

Have an Android project working in Eclipse (4.4.2) ADT, running on Linux (Ubuntu 14.10).

我已经导入到 Android Studio (1.1.0) 并设法摆脱了我的初始编译错误.

I have imported to Android Studio (1.1.0) and managed to get rid of my initial compilation errors.

接下来我想要在我的手机上运行 - 我按下绿色的运行"按钮,过了一会儿我得到一个错误(这在我构建模块时不会出现,只有当我尝试运行)

The next thing I want to d is to run on my phone - I push the green "Run" button and after a little while I get an error (this doesn't show up when I just build module, only when I try to run)

错误是这样的:

错误:任务:myapp:dexDebug"的执行失败.com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' 以非完成零退出值 2

Error:Execution failed for task ':myapp:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2

过去 4 小时一直在查看 SO,但没有找到任何与我的项目相关的内容.还有其他地方可以找到更有用的错误吗?

Been looking through SO for the last 4 hours and not found anything that seems relevant to my project. Is there another place I can look to find a more useful error?

Aaarghh - 只是重新创建了整个项目(而不是信任导入向导) - 我创建了一个新的 Android Studio 项目,导入了我的代码和资源,然后解决了所有编译和依赖错误.完成了清晰的构建,然后尝试运行....同样该死的错误!完全相同的.我做错了什么????

Aaarghh - just recreated the entire project(rather than trusting the import wizard) - I created a new Android Studio project, imported my code and resources and then solved all the compilation and dependency errors. Got through to a clear build then tried to run....same damn error! Exactly the same. What am I doing wrong????

发布新的 build.gradle 以供参考:

New build.gradle posted for reference:

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
    applicationId "com.mycompany.app_Name"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories { mavenCentral()
    maven { url 'https://maven.fabric.io/public' } }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile project(':swipeListView')
compile 'com.sothree.slidinguppanel:library:3.0.0'
compile files('libs/volley.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/commons-codec-1.8.jar')
compile files('libs/linkedin-j-android.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/core.jar')
compile files('libs/gcm.jar')
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
    transitive = true;
}
compile project(':myImportedProject')
}

还尝试使用我的密钥库导出为 APK:出现类似错误:

Also tried to export as an APK with my keystore: got a similar error:

错误:任务:app:dexRelease"的执行失败.com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' 以非完成零退出值 2

Error:Execution failed for task ':app:dexRelease'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2

推荐答案

啊哈!

似乎答案更进一步:错误是

Seems the answer was further up in trace: The error was

com.android.dex.DexException: 多个 dex 文件定义了 Lcom/nineoldandroids/animation/Animator$AnimatorListener;

com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;

所以我在这里找到了答案:

So I found the answer here:

ListViewAnimations 库导致 TOP-LEVEL-EXCEPTION

诀窍的一部分不仅是在 build.gradle 中添加一行说

Part of the trick is not only to add the line to build.gradle saying

compile files('libs/nineoldandroids-2.4.0.jar')

还要从 libs 目录中删除 JAR.

but also to remove the JAR from the libs directory.

现在我有更多的链接问题,但我想我会把它们留给另一个问题.

Now I have more linking issues but I'll leave them for another question I guess.

这篇关于从 Eclipse 导入到 Android Studio 后无法运行任务“:app:dexDebug"的执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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