ben
ben

Reputation: 1122

project built failed: Task 'compileDebug' is ambiguous in root project

After i sync my project with gradle files everything goes fine and i get BUILD SUCCESSFUL message on the gradle console, but when i run my project i'm getting this message:

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

and when i run stacktrace i get this:

FAILURE: Build failed with an exception.

* What went wrong:          
Task 'compileDebug' is ambiguous in root project 'PROJECT_NAME'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidT
estAidl', 'compileDebugAndroidTestJava', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndr
oidTestSources', 'compileDebugJava', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugSources', 'compileDebugUnitTes
tJava', 'compileDebugUnitTestSources'.

* Try:                      
Run gradlew tasks to get a list of available tasks. Run with --info or --debug option to get more log output.

now i don't know why i'm getting this error. at first i added few jars file to the libs folder and to the gradle file and it run well with no errors but now from some reason it doesn't. even after i removed the jars from the gradle it still doesn't compile. So if someone can please explain to my what does compile debug means and why do i get this error.

gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "PACKAGE_NAME"
        minSdkVersion 15
        targetSdkVersion 21
        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:22.0.0'
//    compile files('jsoup-1.8.1.jar')
//    compile files('ytd2.jar')
//    compile files('youtubeSearchApi.jar')
}

and manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="PACKAGE_NAME" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Upvotes: 4

Views: 11885

Answers (1)

dspano
dspano

Reputation: 1640

I had a similar issue when running the task:

gradle compile

FAILURE: Build failed with an exception.

* What went wrong:
Task 'compile' is ambiguous in root project 'testApp'. Candidates are:'compileJava', 'compileTestJava'.`

I thought this was an issue with compile on my dependency, but this was an issue on the task itself. I needed to run the task as:

gradle compileJava

My best guess is that if you are not using a command like "gradle compileDebug" then one of the android configurations are executing the task and it is not working well with your build.gradle.

Here is a link that seems to relate specifically to your issue. Click Here

Upvotes: 3

Related Questions