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)
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'
Update: Google has just fixed the problem in version 4.3.8
( Release Notes )
An updated version of the google-services plugin for Android (v4.3.8) is now available. For more information, see the Firebase Android SDK Release Notes .
The error came from classpath 'com.google.gms:google-services:4.3.6'
Go back to version 4.3.5
dependencies {
classpath 'com.google.gms:google-services:4.3.5'
}
Instead of 4.3.6
dependencies {
classpath 'com.google.gms:google-services:4.3.6'
}
In fact, version
4.3.6
is responsible for this error. The easiest way is to go back to the previous version until it is fixed
Caused by: java.lang.RuntimeException: com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method setVariantDir()
You should use the latest possible version.
DO
dependencies {
classpath 'com.google.gms:google-services:4.3.8'
}
Addition to RRiven fix, I started getting error Plugin with id 'maven' not found after RRiven fix.
I fixed it with downgrading gradle version to 6.9 from file -> project structure -> project -> gradle version
Set Code in build.gradle(Project)
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.google.gms:google-services:4.3.5'
Set Line in gradle-wrapper
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Best way. Google has resolved it.
classpath 'com.google.gms:google-services:4.3.8'
Go to the latest version now of 4.3.8
https://developers.google.com/android/guides/releases https://firebase.google.com/support/release-notes/android#google-services_plugin_v4-3-8
In Kotlin , Gradle version 7.3.3
1- build.gradle (Project)
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2- build.gradle (Module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.