【发布时间】:2016-01-06 00:29:13
【问题描述】:
每次我尝试运行我的项目、清理它或构建它时,我都会收到一个 gradle 错误:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Task 'compile' is ambiguous in root project 'FifiFun2'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTestJavaWithJavac', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources', 'compileLint', 'compileReleaseAidl', 'compileReleaseJavaWithJavac', 'compileReleaseNdk', 'compileReleaseRenderscript', 'compileReleaseSources', 'compileReleaseUnitTestJavaWithJavac', 'compileReleaseUnitTestSources'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
我尝试使用上述选项(stacktrace、info、debug)运行 gradle 任务,但没有任何帮助。
分级:
// 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.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
主 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.user_pc.myapplication"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
}
settings.gradle 文件:
include ':app'
问题截图:
【问题讨论】:
-
可以添加主模块的gradle文件吗?和 settings.gradle ?
-
能否发一张模块设置的截图(快捷键F4)?和/或我在上述评论中询问的文件?
-
@Kalem 已发,请看,。
-
看看这个stackoverflow.com/a/29834581/665823。换句话说,尝试使缓存无效并重新启动(File > Invalidate ..)
-
@Kalem 仍然无法正常工作......
标签: android android-studio gradle android-gradle-plugin