我已阅读有关解决此问题的所有其他建议,例如: Cannot build android project using Android Studio - Gradle 1.7但它没有解决我的问题。
我开始使用--debug,它给了我输出:
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
的build.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并使用播放服务特别是google-maps?
答案 0 :(得分:4)
最后,我找到了一个适合我的“解决方案”。
查看gradle的输出(使用--debug运行),您可以看到ERROR发生之前的最后一个INFO:
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问题。
但是,如果有人有想法,我仍然有兴趣找出我从构建中排除的模块的真正问题。