Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method implementation() for arguments

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'

} 
like image 774
user7856586 Avatar asked Dec 10 '17 22:12

user7856586


1 Answers

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

like image 138
Roberto Martucci Avatar answered Sep 26 '22 13:09

Roberto Martucci