warfo09
warfo09

Reputation: 157

Could not find method implementation() for arguments [com.google.android:support-v4:r7]

I'm a total Android / Java newbie, and came across a project I want to compile below:

https://github.com/maxamillion32/Android-Firebase-mapping

It is a bit old and maybe that's why it's causing me issues.

First error I got about Build Tools 24.0.1, which I downloaded. Now I get the following error which I cannot resolve:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method implementation() for arguments [com.google.android:support-v4:r7] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I've checked my Dependencies in File>Project Structure and com.google.android:support-v4:r7 is there.

build.gradle (Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (app)

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.mimming.hacks.starter"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:23.4.0'
    implementation 'com.google.android.gms:play-services:9.6.1'
    testImplementation 'junit:junit:4.12'

//    compile 'com.firebase:firebase-client-android:2.5.2+'
    apply plugin: 'com.google.gms.google-services'
    implementation 'com.google.firebase:firebase-database:9.6.1'

}

Any ideas? Thank you!

Upvotes: 1

Views: 8769

Answers (1)

Android_id
Android_id

Reputation: 1591

The gradle version used seems to be of lower version, in-order to use implementation gradle version should be above 3

  1. You should replace your dependencies in build.gradle to latest version.
classpath 'com.android.tools.build:gradle:3.6.3'
  1. Also you will have to upgrade the distributionUrl also
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

As you already mentioned you have updated the buildToolsVersion, this should work fine and also make sure all the dependencies are using implementation and not compileas compile is deprecated.

Upvotes: 2

Related Questions