When testing the release build in Android, while listening to onSnapshot
, I'm seeing this exception -
java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.firestore.MetadataChanges" on path: DexPathList[[zip file "/data/app/co.eventstream.GamePlatform-8j9QYyRUi_t25hi2AtV4kQ==/base.apk"
Works well in development mode though and in iOS.
Contents of app/build.gradle
:
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation "com.google.android.gms:play-services-base:15.0.0"
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-firestore:15.0.0"
implementation "com.google.firebase:firebase-database:15.0.0"
implementation "com.google.firebase:firebase-messaging:15.0.2"
implementation "com.google.firebase:firebase-perf:15.1.0"
implementation "com.google.firebase:firebase-invites:15.0.1"
RNFirebase - "react-native-firebase": "^4.0.7"
ReactNative - 0.52.2
Platform - Android
Firebase Module - Firestore
same error with me
@UADACID delete node_modules
and run npm install
again or upgrade to 4.1.0
. Try those.
@steverob are using proguard minify in release mode on your android build? If you are can you try adding the rules I mentioned over here to your proguard rules (/android/app/proguard-rules.pro)
Actually, it's probably not that, MetadataChanges was added in Firestore 16, which is supported in v4.1.0. v4.0.7 should be fixed at v15 though so shouldn't be erroring...
For now to work around this you could upgrade to v4.1.0 this should stop happening, upgrade notes are on the release: https://github.com/invertase/react-native-firebase/releases/tag/v4.1.0 - nothing too major.
Hi same error for me but in 4.1.0
> Task :react-native-firebase:compileDebugJavaWithJavac FAILED
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:20: error: cannot find symbol
import com.google.firebase.firestore.MetadataChanges;
^
symbol: class MetadataChanges
location: package com.google.firebase.firestore
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:18: error: cannot find symbol
import com.google.firebase.firestore.MetadataChanges;
^
symbol: class MetadataChanges
location: package com.google.firebase.firestore
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:94: error: cannot find symbol
MetadataChanges metadataChanges;
^
symbol: class MetadataChanges
location: class RNFirebaseFirestoreCollectionReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:99: error: cannot find symbol
metadataChanges = MetadataChanges.INCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreCollectionReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:101: error: cannot find symbol
metadataChanges = MetadataChanges.EXCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreCollectionReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:97: error: cannot find symbol
MetadataChanges metadataChanges;
^
symbol: class MetadataChanges
location: class RNFirebaseFirestoreDocumentReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:101: error: cannot find symbol
metadataChanges = MetadataChanges.INCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreDocumentReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/react-native-app-autonome/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:103: error: cannot find symbol
metadataChanges = MetadataChanges.EXCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreDocumentReference
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
8 errors
FAILURE: Build failed with an exception.
With that config :
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:15.0.2"
implementation "com.google.firebase:firebase-core:15.0.2"
compile "com.google.android.gms:play-services-auth:15.0.2"
@skymax406 you need v16 of the firestore dependency: implementation "com.google.firebase:firebase-firestore:16.0.0"
@Salakar its not working :(
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
// Firebase dependencies
implementation "com.google.firebase:firebase-firestore:16.0.0"
implementation "com.google.android.gms:play-services-base:15.0.2"
implementation "com.google.firebase:firebase-core:15.0.2"
Same error
Seeing something similar but possibly related - just started getting these today after upgrading from 4.0.1.
"react-native-firebase": "^4.1.0",
"react-native": "0.54.0",
Happens only on Android.
Whenever I call .onSnapshot(...
on a collectionReference
after calling an .orderBy(...
I get an error:
com.facebook.react.bridge.ReadableNativeMap cannot be cast to java.util.Map
applyOrders
RNFirebaseFirestoreCollectionReference.java:190
...
Tried doing:
Downgrading react-native-firebase
to 4.0.7
has worked for me ....
i am solved by using 4.0.4,
Also resorted to downgrading..... When downgrading from 4.1.0 make sure to not only modify package.json
and refresh node_modules
, but also change the app/build.gradle dependencies to what they were before the upgrade to 4.1.0. You then need to execute ./gradlew clean
before building the app again.
Took me a while to realise that...
@OhadRon I have maked a lot of ./gradlew clean
Is somebody able to run ./gradlew app:dependencies
from their android
directory when using 4.1.0 and take a look at what version of the firebase-firestore
lib is being pulled through?
@chrisbianca I have a same problem.
./gradlew app:dependencies
This dependencies:
dependencies.txt
@skymax406 it is work thanks 馃憤
"react": "^16.3.2",
"react-native": "^0.55.4",
"react-native-firebase": "4.0.7",
@dbyilmaz can you update to v4.1.0 of react-native-firebase
and set the firebase-firestore
dependency in your build.gradle
to v16.0.0 ?
I did @chrisbianca. But it throws an error.
Gradle dependencies version have to same for work properly.
> Task :app:processDebugGoogleServices FAILED
Found com.google.firebase:firebase-firestore:16.0.0, but version 12.0.1 is needed for the google-services plugin.
It's clear to me that this is a misconfiguration. MetadataChanges
was added into v4.1.0 of RNFirebase to support v16 of firebase-firestore
.
In order for this to work, you have to follow all of the instructions set out in the release notes here: https://github.com/invertase/react-native-firebase/releases/tag/v4.1.0
This includes, updating the versions of the google-services plugin and android tools plugin, and updating the versions of the android libraries to the versions indicated in the release notes.
I'm closing this as it's not an issue with the library.
@chrisbianca sorry, but i have meticulously follow all instructions of release change logs and this is my config:
android/app/build.gradle
compile(project(':react-native-firebase')) {
transitive = false
}
// RNFirebase required dependencies
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.android.gms:play-services-auth:15.1.0"
implementation "com.google.android.gms:play-services-base:15.0.0"
// RNFirebase optional dependencies
implementation "com.google.firebase:firebase-ads:15.0.0"
implementation "com.google.firebase:firebase-config:15.0.0"
implementation "com.google.firebase:firebase-crash:15.0.2"
implementation "com.google.firebase:firebase-database:15.0.0"
implementation "com.google.firebase:firebase-firestore:16.0.0"
implementation "com.google.firebase:firebase-functions:15.0.0"
implementation "com.google.firebase:firebase-invites:15.0.1"
implementation "com.google.firebase:firebase-messaging:15.0.2"
implementation "com.google.firebase:firebase-perf:15.1.0"
implementation "com.google.firebase:firebase-storage:15.0.2"
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
android/build.gradle
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
}
}
def googlePlayServicesVersion = '12.0.1'
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url "https://jitpack.io"}
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.28.0'
eachDependency { DependencyResolveDetails details ->
if (requested.group == 'com.google.android.gms') {
details.useVersion "$googlePlayServicesVersion"
}
if (requested.group == 'com.google.firebase') {
details.useVersion "$googlePlayServicesVersion"
}
}
}
}
}
}
I have used a ./gradlew clean
And the issue is the same, if it's a misconfiguration problem, what is explain in the release change log is not the right solution, or at least it does not work for me. Because i have all the same versions.
@skymax406 can you write your error message?
Sure
> Task :react-native-firebase:compileDebugJavaWithJavac FAILED
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:20: error: cannot find symbol
import com.google.firebase.firestore.MetadataChanges;
^
symbol: class MetadataChanges
location: package com.google.firebase.firestore
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:18: error: cannot find symbol
import com.google.firebase.firestore.MetadataChanges;
^
symbol: class MetadataChanges
location: package com.google.firebase.firestore
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:94: error: cannot find symbol
MetadataChanges metadataChanges;
^
symbol: class MetadataChanges
location: class RNFirebaseFirestoreCollectionReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:99: error: cannot find symbol
metadataChanges = MetadataChanges.INCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreCollectionReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreCollectionReference.java:101: error: cannot find symbol
metadataChanges = MetadataChanges.EXCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreCollectionReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:97: error: cannot find symbol
MetadataChanges metadataChanges;
^
symbol: class MetadataChanges
location: class RNFirebaseFirestoreDocumentReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:101: error: cannot find symbol
metadataChanges = MetadataChanges.INCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreDocumentReference
/mnt/3485f5c2-2fbe-4ab4-a5d4-c64c3a0c5673/Projets/smarthome-react-native-application/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreDocumentReference.java:103: error: cannot find symbol
metadataChanges = MetadataChanges.EXCLUDE;
^
symbol: variable MetadataChanges
location: class RNFirebaseFirestoreDocumentReference
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
8 errors
@skymax406 the problem is probably because you left this in android/build.gradle
:
if (requested.group == 'com.google.firebase') {
details.useVersion "$googlePlayServicesVersion"
}
With react-native-firebase
v4.1.0 the explicit versions are now set in android/app/build.gradle
.
To confirm which are used, run ./gradlew app:dependencies
Note: I did have the same issue as you initially, and it was because I was using firebase-firestore:15.0.0
instead of firebase-firestore:16.0.0
You are right ! I must have been wrong in my tests, I tried without and it had not changed anything.
And now it works, the problem came from there aparemment! :+1:
Thx dude !
Good spot @jeanregisser !
Most helpful comment
@skymax406 the problem is probably because you left this in
android/build.gradle
:With
react-native-firebase
v4.1.0 the explicit versions are now set inandroid/app/build.gradle
.To confirm which are used, run
./gradlew app:dependencies
Note: I did have the same issue as you initially, and it was because I was using
firebase-firestore:15.0.0
instead offirebase-firestore:16.0.0