我的Android版本是2.3.3。我更新了android sdk(26)。更新后我收到错误。我在build.gradle上遇到了麻烦。我的代码有什么问题?如何使用DSL实现()?如何配置此项目以运行?
build.gradle(Project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// 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
}
build.gradle(Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.ppl.restaurant"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
dependencies {
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:26.0.1'
compile "com.android.support:support-core-utils:26.0.1"
implementation 'info.androidhive:barcode-reader:1.1.2'
implementation 'com.google.android.gms:play-services-vision:11.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
错误消息
Error:(38, 0) Gradle DSL method not found: 'implementation()'
Possible causes:<ul><li>The project 'Restaurant' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
<a href="fixGradleElements">Upgrade plugin to version 2.3.3 and sync project</a></li><li>The project 'ABC' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
答案 0 :(得分:1)
如果你想使用&#34;编译&#34;和android studio 2.3,使用这个:
编译&#39; com.facebook.android:facebook-login:4.28.0&#39;
这对我有用。
答案 1 :(得分:0)
正如您在官方文档中所述,implementation()
DLS要求(目前)
尝试在gradle-wrapper.properties
中使用:
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
作为Android使用的gradle插件:
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
的更多信息
答案 2 :(得分:0)
我已经解决了这个问题:
编译'com.facebook.android:facebook-login:4.28.0'
你需要android studio 3.0才能使用“实现”,但android studio 2.3可以使用“compile”
P.D。:对不起我的英文。
答案 3 :(得分:0)
您可以解决该问题,尝试一下,
build.gradle(项目)文件 buildscript 和 allprojects 区域
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
build.gradle(模块)文件依赖区域
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}