android - gradle错误:错误:找不到参数的方法实现()
问题描述
我正在尝试将 Firebase 添加到我在 android studio 中的聊天应用程序中,但所有提供build.gradle
的插件都没有同步。
我在下面尝试了一些代码:
classpath 'com.google.gms:google-services:4.2.0' implementation 'com.google.firebase:firebase-core:16.0.7'
然后来了
错误:在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找不到参数 [com.google.firebase:firebase-core:16.0.7] 的方法 implementation()。
解决方案
将 Firebase 添加到我的 Ionic 应用程序时,我遇到了同样的错误。事实证明,当这条线应该放在应用程序级别(见下文)时,我把这条线implementation 'com.google.firebase:firebase-core:16.0.1'
放在了dependencies
found within之下。buildscript
dependencies
放在implementation 'com.google.firebase:firebase-core:16.0.1'
这里:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'com.google.firebase:firebase-core:16.0.1'
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.android.support:support-annotations:27.+"
compile "com.android.support:support-v4:24.1.1+"
compile "com.google.firebase:firebase-core:16.0.+"
compile "com.google.android.gms:play-services-analytics:11.0.1"
// SUB-PROJECT DEPENDENCIES END
}
不在这里:
buildscript {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
如果有帮助,我在项目级build.gradle
文件底部附近找到了应用级依赖项部分。
祝你好运!