gpt4 book ai didi

java - AndroidStudio : Gradle build failed for task 'app:preDexDebug (ProcessException, ExecException,非零退出值1)

转载 作者:太空宇宙 更新时间:2023-11-03 13:17:39 24 4
gpt4 key购买 nike

如果我将 minSdkVersion 设置为 17,我能够毫无问题地构建和运行整个项目,但是如果我将 minSdkVersion 设置为 21,如果我尝试运行该应用程序(构建仍然可以正常工作),它会出现以下错误.

我已经阅读了有关解决此问题的所有其他建议,例如Cannot build android project using Android Studio - Gradle 1.7但这并没有解决我的问题。

我用 --debug 启动了 gradle,它给了我输出:

20:39:10.077 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
20:39:10.078 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'.
20:39:10.129 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
20:39:10.129 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
20:39:10.244 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe''
20:39:10.246 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
20:39:10.247 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with exit value 1 (state: FAILED)
20:39:10.254 [INFO] [org.gradle.api.Project] processing archive D:\Benutzer\Henrik\Eigene Dokumente\Project\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-appstate\8.1.0\jars\classes.jar...
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF


20:39:10.255 [ERROR] [org.gradle.api.Project] AGPBI: {"kind":"SIMPLE","text":"no classfiles specified","position":{},"original":"no classfiles specified"}


20:39:10.271 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:preDexDebug'
20:39:10.271 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :app:preDexDebug FAILED
20:39:10.272 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:preDexDebug (Thread[Daemon worker Thread 12,5,main]) completed. Took 1 mins 25.716 secs.
20:39:10.272 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 12,5,main]] finished, busy: 1 mins 32.723 secs, idle: 0.088 secs

20:39:10.277 [ERROR] [org.gradle.BuildExceptionReporter]
20:39:10.277 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
20:39:10.277 [ERROR] [org.gradle.BuildExceptionReporter]
20:39:10.278 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
20:39:10.278 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:preDexDebug'.
20:39:10.278 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 1
20:39:10.278 [ERROR] [org.gradle.BuildExceptionReporter]
20:39:10.278 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
20:39:10.278 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.

20:39:10.279 [LIFECYCLE] [org.gradle.BuildResultLogger]
20:39:10.279 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
20:39:10.279 [LIFECYCLE] [org.gradle.BuildResultLogger]
20:39:10.279 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 1 mins 38.519 secs

构建.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "de.project.test"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.hannesdorfmann.mosby:mvp:2.0.0'
compile 'com.hannesdorfmann.mosby:viewstate:2.0.0'
compile 'com.google.guava:guava:18.0'
// Dagger 2 and Compiler
compile 'com.google.dagger:dagger:2.0.1'
apt "com.google.dagger:dagger-compiler:2.0.1"
compile 'javax.annotation:jsr250-api:1.0'
}

更新如果我删除 'com.google.android.gms:play-services:8.1.0' 的所有用法以及它运行的构建文件中的编译条目。因此,如果我不使用“com.google.android.gms:play-services:8.1.0”或者如果我将 minSDK 设置为 17,它就会运行,但这不是解决方案。有谁知道我如何使用 minSDK 21 和使用播放服务,尤其是谷歌地图?

最佳答案

最后我找到了一个对我有用的“解决方案”。

查看 gradle 的输出(使用 --debug 运行),您可以看到错误发生前的最后一个信息是:

20:39:10.254 [INFO] [org.gradle.api.Project] processing archive D:\Benutzer\Henrik\Eigene Dokumente\Project\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-appstate\8.1.0\jars\classes.jar...

我在 build.gradle 中排除了这个模块(play-services-appstate,无论它做什么)并且它可以工作。

compile ('com.google.android.gms:play-services:8.1.0'){
exclude module: 'play-services-appstate'
}

或者,如果您不需要整个播放服务库,例如只是谷歌地图,你可以改变

compile 'com.google.android.gms:play-services:8.1.0'

compile 'com.google.android.gms:play-services-maps:8.1.0'

这也对我有用。

因此,如果您遇到相同的错误,我建议您使用 --debug 运行 gradle 并排除在错误发生之前命名的模块(如果可以的话)。 preDexDebug 失败真的很棘手。可能有很多原因(依赖项、java 版本等),所以我建议您也查看有关此失败的许多其他 stackoverflow 问题。

但是,如果有人有想法,我仍然有兴趣确定我从构建中排除的模块的真正问题。

关于java - AndroidStudio : Gradle build failed for task 'app:preDexDebug (ProcessException, ExecException,非零退出值1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33400596/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com