[英]Android app won't launch because of Gradle issue in Android Studio
我正在尝试使用我的Samsung /虚拟机编译我的android项目,但出现以下错误:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java''
finished with non-zero exit value 2
我在任何地方都找不到答案,请问有什么想法吗?
尝试在gradle中启用多dex文件支持。
将以下代码添加到您的build.gradle
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
据我所知,该错误与JDK或gradle本身无关,并且可能有很多原因,例如:
您可以尝试在gradle中启用Multi dex支持:
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
或者只是尝试通过删除一些不必要的库来最小化应用程序。
为此,请在Android Studio中执行以下命令:
gradlew -q dependencies yourProjectName_usually_app:dependencies --configuration compile
搜索列出的依存关系中的重复项(标有星号*)并将其删除。
在此问题中,列出了更多的可能性。
classpath 'com.android.tools.build:gradle:1.3.0' -> Should be 1.3.1
buildToolsVersion '23.0.0' -> Should be '23.0.2'
还添加
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
清理您的代码并重新构建
For me the problem was, i had put a unnecessary compile library code in build.gradle
dependencies {
compile 'com.google.android.gms:play-services:7.5.0'
}
which was causing over 65k methods, so removed it,gradle sync, cleaned project, and then ran again and then this error stopped. I needed just maps and gcm so i put these lines and synced project
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
Hi people i again encountered this problem and this time it was because of changing build tools version and it really required me to enable multidex..so i added these my app's build.gradle file..
defaultConfig {
applicationId "com.am.android"
minSdkVersion 13
targetSdkVersion 23
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
}
And create a class that extends Application class and include this method inside the class..
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
also include in OnCreate method too
@Override
public void onCreate() {
MultiDex.install(this);
super.onCreate();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.