1
我这个问题,因为2-3个小时我stucked。我尝试了许多类似问题的解决方案,但都没有成功。 gradle构建工作正常,但在将min sdk级别从23更改为17之后,android studio开始给我提供此错误。摇篮DSL方法:“编译()项目‘机器人’可以使用一个版本的摇篮不包含的方法
错误:(32,0)摇篮DSL方法未找到:“编译()”可能的原因:
项目“机器人”可以使用版本的Android摇篮的插件不包含该方法(例如'testCompile'在1.1.0中添加)。 将插件升级到版本2.3.3和同步项目
项目'android'可能使用不包含该方法的Gradle版本。 打开摇篮封装文件
构建文件可能丢失一个摇篮插件。 应用摇篮插件
下面是我gradle这个文件:
的build.gradle(项目:机器人)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
的build.gradle(模块:APP)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.google.transporttracker"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
resValue "string", "build_transport_id", (project.findProperty("build_transport_id") ?: "")
resValue "string", "build_email", (project.findProperty("build_email") ?: "")
resValue "string", "build_password", (project.findProperty("build_password") ?: "")
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
productFlavors {
}
}
ext {
support = '23.2.0'
playServices = '10.2.4'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:$support" compile "com.android.support:cardview-v7:$support" compile "com.android.support:design:$support" compile "com.google.android.gms:play-services-gcm:$playServices" compile "com.google.android.gms:play-services-location:$playServices" compile "com.google.firebase:firebase-core:$playServices" compile "com.google.firebase:firebase-auth:$playServices" compile "com.google.firebase:firebase-config:$playServices" compile "com.google.firebase:firebase-crash:$playServices" compile "com.google.firebase:firebase-database:$playServices" compile 'com.android.support.constraint:constraint-layout:1.0.2'
classpath 'com.google.gms:google-services:3.0.0'
compile 'com.google.android.gms:play-services-maps:10.2.4'
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
尝试改变'“''到'''在dependencies'。此外,我不认为你需要'classpath'依赖关系删除also.Also突破编译语句为单行。 –