这是我的android gradle文件。我收到错误的android gradle插件,它不包含该方法(例如,在1.1.0中添加了'testcompile')。我该如何解决这个问题。
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.xxx.xxxx"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-auth:9.2.1'
classpath 'com.android.tools.build:gradle:2.3.3'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'com.android.support.test:runner:0.5'
}
错误
答案 0 :(得分:1)
现在修正后的构建。 gradle看起来像这样,现在我认为错误是"错误:(20,0)未找到Gradle DSL方法:' classpath()' 可能的原因:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.xx.xxxxx"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'com.android.support.test:runner:0.5'
}
答案 1 :(得分:0)
在dependencies
区块中,您必须删除此行
classpath 'com.android.tools.build:gradle:2.3.3'
此行应在buildscript
块中使用,例如:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
答案 2 :(得分:0)
从那里删除classpath 'com.android.tools.build:gradle:2.3.3'
并将其添加到您的顶级build.gradle
文件中。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}