1

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!

warfo09
  • 157
  • 2
  • 15

1 Answers1

2

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.

Android_id
  • 1,521
  • 1
  • 15
  • 33
  • thanks for your reply. unfortunately it doesn't work. I have updated my question with my gradle files. does it work for you? with current one I get `Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'. ` – warfo09 May 05 '20 at 16:46
  • 1
    Add google() above jcenter() in both places in gradle – Android_id May 05 '20 at 16:53
  • Thanks, that helped, however now I get ```Cannot fit requested classes in a single dex file (# methods: 69769 > 65536) ``` I have amended my gradle files in the question. Any idea? – warfo09 May 05 '20 at 17:29
  • 1
    multiDexEnabled true you should use in your gradle and also add the dependency. https://stackoverflow.com/questions/48249633/errorcannot-fit-requested-classes-in-a-single-dex-file-try-supplying-a-main-dex check the link you will get solution:) – Android_id May 06 '20 at 02:02