firebase-android-sdk: Multiple java.lang.ClassNotFoundException in Cloud Firestore (24.1.2)

Since past few months we have been seeing a huge influx of crash issues in the Firestore SDK in our production version of our app Config which is causing the issue:

'com.google.gms:google-services:4.3.13'
firebase_bom = '30.3.2'
'com.google.android.gms:play-services-base:18.1.0'
'com.google.android.gms:play-services-tasks:18.0.2'

Please find the logs below

Fatal Exception: java.lang.RuntimeException: Internal error in Cloud Firestore (24.1.2).
       at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:539)
       at com.google.firebase.firestore.util.AsyncQueue.$r8$lambda$jx84dqgUsF4ojecSMurRqFLFD1Y(AsyncQueue.java)
       at com.google.firebase.firestore.util.AsyncQueue$$InternalSyntheticLambda$0$ee0bb9e76d873eb0dc9297d9a9af24cf74be4371507e5d9f6cdb6af965a9e57b$0.run(AsyncQueue.java)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:7406)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Caused by com.google.android.gms.tasks.RuntimeExecutionException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/CharMatcher;
       at com.google.android.gms.tasks.zzw.getResult(com.google.android.gms:play-services-tasks@@18.0.2:3)
       at com.google.firebase.firestore.remote.FirestoreChannel.lambda$runBidiStreamingRpc$0(FirestoreChannel.java:124)
       at com.google.firebase.firestore.remote.FirestoreChannel.$r8$lambda$ThFui-hvcsrVGYxlBtcTH5vVbvE(FirestoreChannel.java)
       at com.google.firebase.firestore.remote.FirestoreChannel$$InternalSyntheticLambda$0$f566b4153b534aa8580aa93faa9c580a04c89fec85c27cb978c537b6c327c368$0.onComplete(FirestoreChannel.java)
       at com.google.android.gms.tasks.zzi.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:234)
       at java.lang.Thread.run(Thread.java:818)

Caused by java.lang.RuntimeException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/CharMatcher;
       at com.google.android.gms.tasks.zzz.run(com.google.android.gms:play-services-tasks@@18.0.2:2)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java:54)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor.$r8$lambda$MfIJbVuxZtLwosAgPzPA-cU66Ko(ThrottledForwardingExecutor.java)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$InternalSyntheticLambda$0$315eca65e330db056b7a49c0f4857da93273eb5e29c07cc873bd0f103d01177e$0.run(ThrottledForwardingExecutor.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

Caused by java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/CharMatcher;
       at com.google.common.base.Splitter.on(Splitter.java:129)
       at io.grpc.internal.GrpcUtil.<clinit>(GrpcUtil.java:205)
       at io.grpc.okhttp.OkHttpChannelBuilder.<init>(OkHttpChannelBuilder.java:181)
       at io.grpc.okhttp.OkHttpChannelBuilder.forTarget(OkHttpChannelBuilder.java:156)
       at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:47)
       at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:27)
       at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:76)
       at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(GrpcCallProvider.java:99)
       at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6(GrpcCallProvider.java:242)
       at com.google.firebase.firestore.remote.GrpcCallProvider.$r8$lambda$SCD5iiibQ8l4haiO8ofSfE0wIJg(GrpcCallProvider.java)
       at com.google.firebase.firestore.remote.GrpcCallProvider$$InternalSyntheticLambda$1$24dfe1452828c34b25291fc0adb6cd3bc1502d531cb543765315882230811d05$0.call(GrpcCallProvider.java)
       at com.google.android.gms.tasks.zzz.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java:54)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor.$r8$lambda$MfIJbVuxZtLwosAgPzPA-cU66Ko(ThrottledForwardingExecutor.java)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$InternalSyntheticLambda$0$315eca65e330db056b7a49c0f4857da93273eb5e29c07cc873bd0f103d01177e$0.run(ThrottledForwardingExecutor.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

Caused by java.lang.ClassNotFoundException: Didn't find class "com.google.common.base.CharMatcher" on path: DexPathList[[zip file "/data/app/com.letsenvision.envisionai-1/base.apk"],nativeLibraryDirectories=[/data/app/com.letsenvision.envisionai-1/lib/arm, /data/app/com.letsenvision.envisionai-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
       at com.google.common.base.Splitter.on(Splitter.java:129)
       at io.grpc.internal.GrpcUtil.<clinit>(GrpcUtil.java:205)
       at io.grpc.okhttp.OkHttpChannelBuilder.<init>(OkHttpChannelBuilder.java:181)
       at io.grpc.okhttp.OkHttpChannelBuilder.forTarget(OkHttpChannelBuilder.java:156)
       at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:47)
       at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:27)
       at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:76)
       at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(GrpcCallProvider.java:99)
       at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6(GrpcCallProvider.java:242)
       at com.google.firebase.firestore.remote.GrpcCallProvider.$r8$lambda$SCD5iiibQ8l4haiO8ofSfE0wIJg(GrpcCallProvider.java)
       at com.google.firebase.firestore.remote.GrpcCallProvider$$InternalSyntheticLambda$1$24dfe1452828c34b25291fc0adb6cd3bc1502d531cb543765315882230811d05$0.call(GrpcCallProvider.java)
       at com.google.android.gms.tasks.zzz.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java:54)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor.$r8$lambda$MfIJbVuxZtLwosAgPzPA-cU66Ko(ThrottledForwardingExecutor.java)
       at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$InternalSyntheticLambda$0$315eca65e330db056b7a49c0f4857da93273eb5e29c07cc873bd0f103d01177e$0.run(ThrottledForwardingExecutor.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

One interesting thing to note is that these issues are only coming for users who are on Android 5 and Android 6. You can see this in the screenshots from the crashlytics.

Screenshot from 2022-08-29 15-38-44

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

@Farasy Yes upgrading to the Guava Android 31.1 worked for us in production as well and now the app is once again stable for older Android versions

So, what helps is to set the Guava version strictly as it looks that at least one dependency in the jungle uses a different version:

    implementation ("com.google.guava:guava") {
        version{
            strictly '31.1-android'
        }
    }

The issue still happen in Android 6 and 5 with the InApp Messaging implementation, even with the next guava versions:

implementation 'com.google.guava:guava:31.1-android' implementation 'com.google.guava:guava:28.0-android' implementation 'com.google.guava:guava:27.0.1-android'

Here is the stacktrace (from emulator Pixel 3 API 23):

Exception io.reactivex.exceptions.UndeliverableException: java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher
  at io.reactivex.plugins.RxJavaPlugins.onError (RxJavaPlugins.java:367)
  at io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:69)
  at io.reactivex.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:57)
  at java.util.concurrent.FutureTask.run (FutureTask.java:237)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:154)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:269)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
  at java.lang.Thread.run (Thread.java:818)
Caused by java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher
  at com.google.common.base.Splitter.on (Splitter.java:129)
  at io.grpc.internal.GrpcUtil.<clinit> (GrpcUtil.java:203)
  at io.grpc.okhttp.OkHttpChannelBuilder.<init> (OkHttpChannelBuilder.java:174)
  at io.grpc.okhttp.OkHttpChannelBuilder.forTarget (OkHttpChannelBuilder.java:149)
  at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget (OkHttpChannelProvider.java:47)
  at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget (OkHttpChannelProvider.java:27)
  at io.grpc.ManagedChannelBuilder.forTarget (ManagedChannelBuilder.java:76)
  at com.google.firebase.inappmessaging.internal.injection.modules.GrpcChannelModule.providesGrpcChannel (GrpcChannelModule.java:41)
  at com.google.firebase.inappmessaging.internal.injection.modules.GrpcChannelModule_ProvidesGrpcChannelFactory.providesGrpcChannel (GrpcChannelModule_ProvidesGrpcChannelFactory.java:39)
  at com.google.firebase.inappmessaging.internal.injection.modules.GrpcChannelModule_ProvidesGrpcChannelFactory.get (GrpcChannelModule_ProvidesGrpcChannelFactory.java:30)
  at com.google.firebase.inappmessaging.internal.injection.modules.GrpcChannelModule_ProvidesGrpcChannelFactory.get (GrpcChannelModule_ProvidesGrpcChannelFactory.java:9)
  at com.google.firebase.inappmessaging.dagger.internal.DoubleCheck.get (DoubleCheck.java:47)
  at com.google.firebase.inappmessaging.internal.injection.components.DaggerUniversalComponent.gRPCChannel (DaggerUniversalComponent.java:180)
  at com.google.firebase.inappmessaging.internal.injection.components.DaggerAppComponent$com_google_firebase_inappmessaging_internal_injection_components_UniversalComponent_gRPCChannel.get (DaggerAppComponent.java:309)
  at com.google.firebase.inappmessaging.internal.injection.components.DaggerAppComponent$com_google_firebase_inappmessaging_internal_injection_components_UniversalComponent_gRPCChannel.get (DaggerAppComponent.java:299)
  at com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule_ProvidesInAppMessagingSdkServingStubFactory.get (GrpcClientModule_ProvidesInAppMessagingSdkServingStubFactory.java:35)
  at com.google.firebase.inappmessaging.internal.injection.modules.GrpcClientModule_ProvidesInAppMessagingSdkServingStubFactory.get (GrpcClientModule_ProvidesInAppMessagingSdkServingStubFactory.java:11)
  at com.google.firebase.inappmessaging.dagger.internal.DoubleCheck.get (DoubleCheck.java:47)
  at com.google.firebase.inappmessaging.internal.GrpcClient_Factory.get (GrpcClient_Factory.java:26)
  at com.google.firebase.inappmessaging.internal.GrpcClient_Factory.get (GrpcClient_Factory.java:8)
  at com.google.firebase.inappmessaging.dagger.internal.DoubleCheck.get (DoubleCheck.java:47)
  at com.google.firebase.inappmessaging.internal.ApiClient.getFiams (ApiClient.java:72)
  at com.google.firebase.inappmessaging.internal.InAppMessageStreamManager.lambda$createFirebaseInAppMessageStream$16$com-google-firebase-inappmessaging-internal-InAppMessageStreamManager (InAppMessageStreamManager.java:261)
  at com.google.firebase.inappmessaging.internal.InAppMessageStreamManager$$ExternalSyntheticLambda16.apply (D8$$SyntheticClass)
  at io.reactivex.internal.operators.maybe.MaybeMap$MapMaybeObserver.onSuccess (MaybeMap.java:82)
  at io.reactivex.internal.operators.maybe.MaybeFilter$FilterMaybeObserver.onSuccess (MaybeFilter.java:89)
  at io.reactivex.internal.operators.maybe.MaybeObserveOn$ObserveOnMaybeObserver.run (MaybeObserveOn.java:104)
  at io.reactivex.Scheduler$DisposeTask.run (Scheduler.java:579)
  at io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:66)