Error on android device when using firebase unity sdk firestore package

Viewed 1003

I'm trying to use the firebase unity sdk in my android app. Specifically the FirebaseFirestore.unitypackage. I can get everything working running my app directly thru unity. But when I do an android build and deploy to my actual device or an emulator I get this error.

java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/my.package.name/cache/firestore_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

and then later down the log it says something similar...

E/firebase: Java class com/google/firebase/firestore/internal/cpp/QueryEventListener not found.  Please verify the AAR which contains the com/google/firebase/firestore/internal/cpp/QueryEventListener class is included in your app

I've attempted to "Build and Run" to an emulator and an actual device directly from unity. I've also attempted to export the project from unity and import it into android studio and create the apk that way, but it ends with same result.

I'm using unity 2020.3.12f1. I'm using the Android SDK Tools installed with Unity

C:\Program Files\Unity\2020.3.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK

I am targeting Android 9.0 API Lebel 28

I'm really not sure what is going on. I'm using another unity firebase package (the auth package) without any problems. But the second I try to use Firestore I start getting this error.

Any help would be appreciated I've been staring at this for days.

Update:

here is a more details on the error stack trace...

06-30 06:14:09.720 32608 32638 W System.err: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/firestore_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.access$300() 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e$1.handleMessage() 06-30 06:14:09.721 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e.run() 06-30 06:14:09.721 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/firestore_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.721 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/google_api_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.722 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/user/0/com.paradise.casino.unity.slots/cache/app_resources_lib.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 06-30 06:14:09.722 32608 32638 W System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "com/google/firebase/firestore/internal/cpp/QueryEventListener" on path: DexPathList[[zip file "/data/app/com.paradise.casino.unity.slots-2/base.apk"],nativeLibraryDirectories=[/data/app/com.paradise.casino.unity.slots-2/lib/arm, /data/app/com.paradise.casino.unity.slots-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] 06-30 06:14:09.725 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 06-30 06:14:09.725 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.access$300() 06-30 06:14:09.725 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e$1.handleMessage() 06-30 06:14:09.726 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e.run() 06-30 06:14:09.924 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 06-30 06:14:09.924 32608 32638 W System.err: at com.unity3d.player.UnityPlayer.access$300() 06-30 06:14:09.924 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e$1.handleMessage() 06-30 06:14:09.925 32608 32638 W System.err: at com.unity3d.player.UnityPlayer$e.run() 06-30 06:14:09.946 32608 32638 E mono-rt : at Firebase.Firestore.TransactionManagerProxy..ctor (Firebase.Firestore.FirestoreProxy) [0x00000] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\TransactionManagerProxy.cs:42 06-30 06:14:09.946 32608 32638 E mono-rt : at Firebase.Firestore.TransactionManager..ctor (Firebase.Firestore.FirebaseFirestore,Firebase.Firestore.FirestoreProxy) [0x00013] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\TransactionManager.cs:45 06-30 06:14:09.946 32608 32638 E mono-rt : at Firebase.Firestore.FirebaseFirestore..ctor (Firebase.Firestore.FirestoreProxy,Firebase.FirebaseApp) [0x00052] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore.cs:59 06-30 06:14:09.947 32608 32638 E mono-rt : at Firebase.Firestore.FirebaseFirestore.GetInstance (Firebase.FirebaseApp) [0x00035] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore.cs:132 06-30 06:14:09.947 32608 32638 E mono-rt : at Firebase.Firestore.FirebaseFirestore.get_DefaultInstance () [0x0000c] in Z:\tmp\tmp.FEeynkVB11\firebase\firestore\client\unity\proxy\FirebaseFirestore.cs:116 06-30 06:14:09.947 32608 32638 E mono-rt : at AuthManager.Start () [0x00005] in C:\Users\myname\Documents\repos\myapp\Assets\Scripts\AuthManager.cs:56

3 Answers

It's a bug in the Unity SDK 8.0.0. I've the same crash on my samsung galaxy s21. Google should fix it in the next firebase-firestore version.

Here is a workaround for this bug. I haven't found the root cause yet. The fix, whatever it is, may not be available for some time.

  1. Copy firestore_cpp_resources.zip into Assets/Plugins/Android of your Unity project.
  2. Change the extension from .zip to .jar (GitHub forbids attaching .jar files, probably for security reasons)
  3. Exit and restart the Unity Editor (not sure if this is required, but it fixed a seemingly-unrelated "duplicate import" build error for me)
  4. Once the fix is released make sure to delete this JAR file since it will likely conflict with future versions of the Unity SDK.

That firestore_cpp_resources.jar file contains the compiled QueryEventListener class that is erroneously absent from the firestore_resources_lib.jar that is bundled with the Firebase Unity SDK 8.0.0. By providing in via this JAR file it is able to be found and used.

It may be a Dex limit issue. Have you enabled ProGuarding at your build settings as stated at the official docs?

Related