Why am I getting AbstractDynamicObject$CustomMessageMissingMethodException error?

Issue

I have just started a new project and am trying to connect to Firebase.

As soon as I try to build my project I got the error:

Could not parse the Android application Module’s Gradle Config

So I looked in my build which told me that jCenter() was deprecated and that I should remove it. When I removed it, everything worked fine. However, when I tried to connect to Firebase I got the error:

AbstractDynamicObject$CustomMessageMissingMethodException.

What may be causing this?

Full stack trace:

    Caused by: java.lang.RuntimeException: com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method setVariantDir() for arguments [debug] on task ':app:processDebugGoogleServices' of type com.google.gms.googleservices.GoogleServicesTask.
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:71)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:54)
    at com.android.build.gradle.internal.profile.AnalyticsResourceManager.recordBlockAtConfiguration(AnalyticsResourceManager.kt:206)
    at com.android.build.gradle.internal.profile.AnalyticsConfiguratorService.recordBlock(AnalyticsConfiguratorService.kt:85)
    at com.android.build.gradle.internal.plugins.BasePlugin.lambda$createTasks$9(BasePlugin.java:582)
    at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt:37)
    at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt)

Solution

I came here because I am getting the same error. Luckily I was updating dependencies when it happened and narrowed it down to:

classpath 'com.google.gms:google-services:4.3.6'

Change it to

classpath 'com.google.gms:google-services:4.3.5'

The error goes away for me. Hopefully for you too

Here is more info on my dependencies.

Running Android Studio 4.2 build April 28 2021

repositories {
        google()
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0'
        classpath 'com.google.gms:google-services:4.3.5'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.0'
        classpath 'com.google.firebase:perf-plugin:1.4.0'

Gradle Plugin 4.2.0
Gradle 7.0.1

//Firebase
    implementation 'com.google.firebase:firebase-ads:20.1.0'
    implementation 'com.google.firebase:firebase-core:19.0.0'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'
    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
    implementation 'com.google.firebase:firebase-auth:21.0.0'
    implementation 'com.google.firebase:firebase-firestore:23.0.0'

Answered By – RRiVEN

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published