【问题标题】:Build error ,Gradle -> Error:Execution failed for task ':app:preDexDebug'. > org.gradle.process.internal.ExecException:构建错误,Gradle -> 错误:任务':app:preDexDebug'的执行失败。 > org.gradle.process.internal.ExecException:
【发布时间】:2015-09-29 19:38:02
【问题描述】:

我使用 Android Studio。

模块应用:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 21
    buildToolsVersion '22.0.1'
    compileOptions {
        encoding "UTF-8"

    }
    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 1
        versionName '1'
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile files('libs/volley.jar')
    compile 'com.google.android.gms:play-services:7.5.0'
}

项目 com.my.app

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

但我收到此错误:

error : Error:Execution failed for task ':app:preDexDebug'.
org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'C:\Program
Files\Java\jdk1.8.0_45\bin\java.exe''

使用 gradlew compileDebug --stacktrace :

* Exception is:
org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in
 root project 'BillionsOfPeople'. Candidates are: 'compileDebugAidl', 'compileDe
bugAndroidTestAidl', 'compileDebugAndroidTestJava', 'compileDebugAndroidTestNdk'
, 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestSources', 'comp
ileDebugJava', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugSourc
es', 'compileDebugUnitTestJava', 'compileDebugUnitTestSources'.

 at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
     at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)

     at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)

    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)

gradlew compileDebug:

FAILURE:构建失败并出现异常。

  • 出了什么问题:任务“compileDebug”在根项目“MyApp”中不明确。候选人是:'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTest Java', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'com pileDebugAndroidTestSources', 'compileDebugJava', 'compileDebugNdk', 'compileDeb ugRenderscript', 'compileDebugSources', 'compileDebugUnitTestJava'、'compileDebuggUnitTestSources'。

注意:我无法运行 sdk 管理器。

【问题讨论】:

    标签: java android debugging compilation


    【解决方案1】:

    我认为问题在于applicationIdbuild.gradle 中的值。它应该包含您的应用程序的完全限定包名称,因为它将是系统用来安装您的应用程序的标识符。 “/**/”对于 dex 包装来说似乎是一个非常矛盾的名称。

    【讨论】:

    • 这个错误非常普遍,可能有很多来源。请提供更多关于你在做什么的背景信息,这个应用程序的架构如何,还有其他 build.gradle 文件等等。相应地更新问题中的 applicationId
    • gradle stacktrace 不完全合格,所以我看不出错误是 NullPointer 还是其他东西。
    • 你确定没有更多关于 JDK 路由执行错误的信息吗?
    • 我有“gradlew compileDebug”部分。
    猜你喜欢
    • 2014-07-13
    • 1970-01-01
    • 2015-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多