Gradle同步失败:找不到方法实现() [英] Gradle Sync failed: Could not find method implementation()
问题描述
尝试解决此错误已有数小时……无法解决它.我是Android Studio的新手
Been trying to resolve this error for hours...cant get it solved. I am a newbie to Android Studio
我的项目级别的build.gradle文件如下
My project level build.gradle file is as follows
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
我的应用程序build.gradle文件如下
And my app build.gradle file is as follows
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.amazonaws.androidtest"
minSdkVersion 8
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
aaptOptions {
cruncherEnabled = false
}
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
}
}
apply plugin: 'com.google.gms.google-services'
尝试同步时出现以下错误
Getting the following error when trying to sync
Gradle sync failed: Could not find method implementation() for arguments [com.google.firebase:firebase-core:16.0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我正在使用Android Studio 2.3
I am using Android Studio 2.3
试图将Gradle升级到版本4,但需要Android Studio3.不能立即安装Android Studio 3.
Tried to upgrade Gradle to version 4 but that requires Android Studio 3. Cant install Android Studio 3 for now.
还添加了Maven网址,作为一些建议的答案.仍然无法正常工作.
Also added the maven url's as some answers suggested. Still not working.
还有其他解决方法吗?
推荐答案
使用构建工具 3.1.4
,它应该是已知的(阅读以下内容):
with build-tools 3.1.4
, it should become known (read below):
classpath "com.android.tools.build:gradle:3.1.4"
但是如果您不能更新Android Studio,请使用 compile
而不是 implementation
.
but if you cannot update Android Studio , use compile
instead of implementation
.
compile "com.google.firebase:firebase-core:16.0.3"
这篇关于Gradle同步失败:找不到方法实现()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!