Vaiden Vaiden - 1 year ago 432
Android Question

Duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

I have an Android project built with React-Native and employing Google Play Services (analytics, cloud messaging, ads). I'm not explicitly using Firebase anywhere.

Tried upgrading the Play Services from 8.4.0 => 9.2.0. Also upgraded the GPS classpath.

buildscript {
dependencies {
classpath ''


dependencies {
compile ''
compile ''
compile ''
compile ''

Notice that I'm not explicitly depending on Firebase anywhere.

Ever since the upgrade I'm getting the following Gradle build error: duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

I know that Firebase comes bundled within the Google Play Services (since 9.0), so I figured something else is compiling and linking with an older version.
So looking at the dependency insight (
gradle -q dependencyInsight --configuration compile --dependency firebase
) I've noticed that firebase-common 9.0.0 is being added on top of 9.2.1:

enter image description here

But I can't for the life of me find out what causes this.

Answer Source

Well - the culprit is React-Native.

The hint was this obscure line that appears on the Gradle console:

google-services plugin could not detect any version for or, default version: 9.0.0 will be used.

The fix? Force the RN library project to link with the correct Firebase version, by adding the following line to its build.gradle:

compile ''

And thus:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download