Could not find method implementation() for arguments
Asked Answered
F

1

7

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'

} 
Fourthly answered 10/12, 2017 at 22:12 Comment(2)
You have to use the plugin 3.x.x to use the implementation DSLLoxodromic
@Gabriele Mariotti thanks, I was not carefulFourthly
R
7

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

Rue answered 10/12, 2017 at 22:36 Comment(3)
Thanks for Your answer. You are partially correct. Setup gradle sometimes can take a lot of time.Fourthly
I find this answer a little bit confusing. Which build.gradle files should be changed? The update parts are not very clear regarding this information.The
@Zerok, I've updated the answer. All the update parts refer the app build.gradle file. The one where you actually declare your dependencies.Rue

© 2022 - 2024 — McMap. All rights reserved.