Android Gradle plugin, issue with Google’s maven repo

After attempt to add Firebase client library com.google.gms:google-services:4.3.2 into root level Gradle config build.grade, I caught error during Android Studio syncing:

Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:86)
... 85 more
Caused by: java.lang.NoSuchFieldError: JAVA_LETTER_OR_DIGIT

Googling have not helped a lot, but changing version did.
Downgrade you Firebase library a bit, e.g down to v 4.2.0 and you sync will complete successfully.
classpath 'com.google.gms:google-services:4.2.0'

Adding an older version helps avoid this exception but it doesn’t solve the root of the problem and it’s not obvious what causes it.

At first I think that it’s because the newest version has appeared in Android Firebase setup guide before actually became available in public Google Maven repo. But searching through the repo helped to find out it’s not the case.

The real problem was with Android Gradle plugin. Mine was ‘com.android.tools.build:gradle:3.0.1’ and it doesn’t work properly with google’s maven repository.
So you have to use google-services library versions available in AndroidTools Repository. Like com.google.gms:google-services:4.2.0 from above which is present in AndroidTools repo while com.google.gms:google-services:4.3.2 is not.

After updating gradle plugin for Android Studio to 'com.android.tools.build:gradle:3.2.0' you need also update gradle wrapper version, otherwise you get error
Minimum supported Gradle version is 4.6. Current version is 4.1.

Fix it by clicking on Android Studio’s suggestion “Fix Gradle wrapper and re-import project” or by yourself, bumping version in %YOUR_PROJECT%/gradle/wrapper/gradle-wrapper.properties file

...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

When all this is done you can finally add to your dependencies actual version from Firebase setup guide:
classpath 'com.google.gms:google-services:4.3.2'

Leave a Reply

Your email address will not be published. Required fields are marked *