错误:找不到 Gradle DSL 方法:'implementiation()'可能的原因:



我正在尝试在我的应用程序中使用 firebase,我完成了Firebase官方网站上列出的所有步骤,了解如何将Google服务插件和Firebase产品添加到我的模块和项目build.gradle中,但我仍然收到以下错误列表:

错误:找不到 Gradle DSL 方法:"实现(("可能 原因:

1-"友好聊天"项目可能使用的是Android版本。 不包含该方法的 Gradle 插件(例如"testCompile" 在 1.1.0 中添加(。

2-"友好聊天"项目可能使用的是 Gradle 的版本 不包含该方法。

3-构建文件可能缺少 Gradle 插件。

我在StackOverflow上提到了可能的解决方案,但我得到了相同的结果。

这是我的项目:buidl.gradle:

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

这是我的应用程序:build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.friendlychat"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementiation 'com.google.firebase:firebase-perf:19.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api 'com.google.android.material:material:1.1.0-alpha06'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test:runner:1.2.0-alpha05'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha05'
}

这是您build.gradle中的错字。您使用了实现而不是实现

更改此内容,如下所示:

implementation 'com.google.firebase:firebase-perf:19.0.4'

而不是

implementiation 'com.google.firebase:firebase-perf:19.0.4'

最新更新