Android 如何在使用“时修复build.gradle错误”;类路径';build:gradle:2.3.3'&引用;
这是我的android gradle文件。我发现错误android gradle插件不包含该方法(例如,在1.1.0中添加了“testcompile”)。我怎样才能解决这个问题Android 如何在使用“时修复build.gradle错误”;类路径';build:gradle:2.3.3'&引用;,android,android-gradle-plugin,Android,Android Gradle Plugin,这是我的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
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'
}
错误
在
依赖项
块中,必须删除此行
classpath 'com.android.tools.build:gradle:2.3.3'
这一行应该用在buildscript
块中,类似于:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
从那里删除
classpath'com.android.tools.build:gradle:2.3.3'
,并将其添加到顶级build.gradle
文件中
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
修正后,现在开始构建。gradle看起来是这样的,现在我将错误定义为“error:(20,0)找不到gradle DSL方法:'classpath()' 可能原因:
它不起作用。按照您的建议进行更改后,您应该在根文件夹中发布build.gradle。它不起作用。按照您的建议进行更改后
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'
}