Could not find method implementation() for arguments

user7856586 picture user7856586 · Dec 10, 2017 · Viewed 14.2k times · Source

I try to run my app, but gradle doesn`t want to compose it.

Can you tell me what should I do ?

Error:(36, 0) Could not find method implementation() for arguments [com.google.firebase:firebase-appindexing:11.6.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

My app build.gradle file

 minSdkVersion 14
        targetSdkVersion 22
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.config
        }
    }
    lintOptions {
        disable 'MissingTranslation'
    }
    productFlavors {
    }
}
dependencies {
    implementation 'com.google.firebase:firebase-appindexing:11.6.2'
    compile project(':AndEngine')
    compile files('libs/gson-2.8.0.jar')
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.firebase:firebase-core:10.2.4'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.android.gms:play-services-ads:10.2.4'
    compile 'com.google.firebase:firebase-ads:10.2.4'
    compile 'com.google.firebase:firebase-crash:10.2.4'

} 

Answer

Roberto Martucci picture Roberto Martucci · Dec 10, 2017

Replace

implementation 'com.google.firebase:firebase-appindexing:11.6.2'

with

compile 'com.google.firebase:firebase-appindexing:11.6.2'

You need to update your gradle version in order to use implementation. You can do that updating your buildscript block in your project build.gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

compile has been deprecated and it will be no longer supported in future gradle releases.

So to let your project compile just change that line as I suggested, but consider to update your gradle version and use implementation for all your dependencies.

UPDATE

You should use the same version for all the modules of your firebase dependencies.

So you could need to update your app build.gradle this way

dependencies {
    compile 'com.google.firebase:firebase-appindexing:11.6.2'
    compile project(':AndEngine')
    compile files('libs/gson-2.8.0.jar')
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.firebase:firebase-core:11.6.2'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.android.gms:play-services-ads:11.6.2'
    compile 'com.google.firebase:firebase-ads:11.6.2'
    compile 'com.google.firebase:firebase-crash:11.6.2'
} 

Or you might have new build errors.

Also

compile 'com.android.support:support-v4:22.2.1'

is not the latest version and might bring new issues.

But I suggest to proceed step by step :)

UPDATE 2

If you declare a dependency for gson this way

compile 'com.google.code.gson:gson:2.8.0'

You don't need

compile files('libs/gson-2.8.0.jar')

It is redundant and plus you can free your libs folder of a useless jar file