Gradle Sync failed: Could not find method implementation()

我怕爱的太早我们不能终老 提交于 2021-01-29 11:00:16

问题


Been trying to resolve this error for hours...cant get it solved. I am a newbie to Android Studio

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" }
    }
}

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.

I am using Android Studio 2.3

Tried to upgrade Gradle to version 4 but that requires Android Studio 3. Cant install Android Studio 3 for now.

Also added the maven url's as some answers suggested. Still not working.

Any other way to resolve this?


回答1:


with build-tools 3.1.4, it should become known (read below):

classpath "com.android.tools.build:gradle:3.1.4"

but if you cannot update Android Studio , use compile instead of implementation.

compile "com.google.firebase:firebase-core:16.0.3"


来源:https://stackoverflow.com/questions/52242480/gradle-sync-failed-could-not-find-method-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!