在我的项目与 gradle文件同步后,一切顺利,我在gradle控制台上获得了 BUILD SUCCESSFUL 消息,但是当我运行我的项目时我就是得到这条消息:
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
当我运行stacktrace时,我得到了这个:
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.
现在我不知道为什么我会收到此错误。起初我将几个jars文件添加到libs文件夹和gradle文件中,它运行良好,没有错误,但现在由于某种原因它没有。即使我从摇篮中取出罐子,它仍然无法编译。因此,如果有人可以向我解释编译调试意味着什么,为什么我会收到此错误。
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')
}
和清单:
<?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>
答案 0 :(得分:1)
运行任务时我遇到了类似的问题:
Click
我认为这是依赖于编译的问题,但这是任务本身的问题。我需要将任务运行为:
gradle compile
FAILURE: Build failed with an exception.
* What went wrong:
Task 'compile' is ambiguous in root project 'testApp'. Candidates are:'compileJava', 'compileTestJava'.`
我最好的猜测是,如果你没有使用像#34; gradle compileDebug&#34;这样的命令。然后其中一个android配置正在执行任务,并且它与build.gradle不兼容。
以下链接似乎与您的问题有关。 Click Here