android studio 执行因 idk-1.8 的任务进程异常而失败 [英] android studio execution failed for task- process exception for idk-1.8
问题描述
在向项目添加 jar 文件后,我似乎无法修复此错误:
I can't seem to fix this error after I add a jar file to the project:
任务 ':app:dexDebug' 执行失败.com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java''完成非零退出值 1
Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
该程序在没有 jar 文件的情况下运行,但是当我添加它时,一切都会构建,但是当我尝试运行它时它给了我这个错误.我已经搜索并尝试了以下解决方案,但没有解决该错误.
The program runs without the jar file but when I add it, everything builds but it gives me this error when I try to run it. I have searched and tried the following solutions but nothing fixed the error.
错误:任务':app:dexDebug 执行失败'.>comcommand 以非零退出值 2 结束
由于这些解决方案都不起作用,我认为这是一个超过 65k 的方法问题,所以我编辑了我的 build.gradle,但问题仍然存在.
https://developer.android.com/tools/building/multidex.html
Since none of these solutions worked I thought it my be a over 65k method problem so I edited my build.gradle but the problem still exists.
https://developer.android.com/tools/building/multidex.html
这是我的应用项目的 build.grade:
This is my build.grade for my app project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
................
minSdkVersion 15
targetSdkVersion 21
multiDexEnabled = true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/xyz.jar')
}
我不知道如何解决这个问题.任何帮助将不胜感激.
I don't know how to fix this problem. Any help would be appreciated.
推荐答案
我在尝试添加普通 Java 模块作为对 Android 模块的依赖时收到此错误消息(也仅在运行而不是构建时).虽然它只发生在 Android Studio 中,而不是来自命令行.
I had this error message (also only when running not building) when attempting to add a plain Java module as a dependency on an Android module. Though it only happened in Android Studio, not from the command line.
我通过在普通 Java 模块的 build.gradle 中包含以下行来解决它:
I solved it by including the following line in the plain Java module's build.gradle:
sourceCompatibility = 1.7
请注意,Android Studio 将此行标记为未使用.
Note that Android Studio marks this line as not used.
这篇关于android studio 执行因 idk-1.8 的任务进程异常而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!