expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
427 stars 91 forks source link

Firestore Promises never complete when running with detox on Android #197

Open blumendorf opened 9 months ago

blumendorf commented 9 months ago

Summary

There is an open issue in detox regarding the 'protobuf-lite' of the 'androidx.test.espresso:espresso-contrib'.

See https://github.com/wix/Detox/issues/3981 and https://github.com/wix/Detox/issues/3957.

The solution that also works for me is to replace

androidTestImplementation('com.wix:detox:+') 

with

androidTestImplementation('com.wix:detox:+') {
    exclude module: "protobuf-lite"
}

I would like to suggest adding this change to the config-plugins.

Config Plugin

@config-plugins/detox

What platform(s) does this occur on?

Android

SDK Version

49.0.13

Reproducible demo

Add something like this to a component tested with detox. The call will never finish.

await firestore()
   .collection('collectionName')
   .get()
   .then((result) => { ... })

The exception raised in 'adb logcat':

10041 10041 E detox   : Failed to sync Espresso manually.
10041 10041 E detox   : java.lang.reflect.InvocationTargetException
10041 10041 E detox   :      at java.lang.reflect.Method.invoke(Native Method)
10041 10041 E detox   :      at org.joor.Reflect.on(Reflect.java:723)
10041 10041 E detox   :      at org.joor.Reflect.call(Reflect.java:427)
10041 10041 E detox   :      at com.wix.detox.espresso.UiAutomatorHelper$2.run(UiAutomatorHelper.java:60)
10041 10041 E detox   :      at com.wix.detox.common.UIThread.postSync$lambda-0(UIThread.kt:19)
10041 10041 E detox   :      at com.wix.detox.common.UIThread.$r8$lambda$_Z79tZbTHJk11n0eI4HC0LzUHu0(Unknown Source:0)
10041 10041 E detox   :      at com.wix.detox.common.UIThread$$ExternalSyntheticLambda1.call(Unknown Source:2)
10041 10041 E detox   :      at java.util.concurrent.FutureTask.run(FutureTask.java:264)
10041 10041 E detox   :      at android.os.Handler.handleCallback(Handler.java:958)
10041 10041 E detox   :      at android.os.Handler.dispatchMessage(Handler.java:99)
10041 10041 E detox   :      at android.os.Looper.loopOnce(Looper.java:205)
10041 10041 E detox   :      at android.os.Looper.loop(Looper.java:294)
10041 10041 E detox   :      at android.app.ActivityThread.main(ActivityThread.java:8177)
10041 10041 E detox   :      at java.lang.reflect.Method.invoke(Native Method)
10041 10041 E detox   :      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
10041 10041 E detox   :      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
10041 10041 E detox   : Caused by: java.lang.RuntimeException: Internal error in Cloud Firestore (24.8.1).
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:545)
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue$$ExternalSyntheticLambda6.run(Unknown Source:2)
10041 10041 E detox   :      at android.os.Handler.handleCallback(Handler.java:958)
10041 10041 E detox   :      at android.os.Handler.dispatchMessage(Handler.java:99)
10041 10041 E detox   :      at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:14)
10041 10041 E detox   :      at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:8)
10041 10041 E detox   :      at androidx.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:17)
10041 10041 E detox   :      at androidx.test.espresso.base.UiControllerImpl.loopMainThreadForAtLeast(UiControllerImpl.java:9)
10041 10041 E detox   :      ... 16 more
10041 10041 E detox   : Caused by: java.lang.NoSuchMethodError: No static method registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite;)V in class Lcom/google/protobuf/GeneratedMessageLite; or its super classes (declaration of 'com.google.protobuf.GeneratedMessageLite' appears in /data/app/~~OANV8CO0nVBhQX8gR5wNgA==/xxx.xxxx.xxx.com.test-u_jyK0-SOpPnYTb9MmWoAw==/base.apk)
10041 10041 E detox   :      at com.google.firestore.v1.ListenRequest.<clinit>(ListenRequest.java:873)
10041 10041 E detox   :      at com.google.firestore.v1.FirestoreGrpc.getListenMethod(FirestoreGrpc.java:414)
10041 10041 E detox   :      at com.google.firebase.firestore.remote.WatchStream.<init>(WatchStream.java:61)
10041 10041 E detox   :      at com.google.firebase.firestore.remote.Datastore.createWatchStream(Datastore.java:138)
10041 10041 E detox   :      at com.google.firebase.firestore.remote.RemoteStore.<init>(RemoteStore.java:174)
10041 10041 E detox   :      at com.google.firebase.firestore.core.MemoryComponentProvider.createRemoteStore(MemoryComponentProvider.java:103)
10041 10041 E detox   :      at com.google.firebase.firestore.core.ComponentProvider.initialize(ComponentProvider.java:153)
10041 10041 E detox   :      at com.google.firebase.firestore.core.FirestoreClient.initialize(FirestoreClient.java:296)
10041 10041 E detox   :      at com.google.firebase.firestore.core.FirestoreClient.lambda$new$0$com-google-firebase-firestore-core-FirestoreClient(FirestoreClient.java:114)
10041 10041 E detox   :      at com.google.firebase.firestore.core.FirestoreClient$$ExternalSyntheticLambda14.run(Unknown Source:8)
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$2(AsyncQueue.java:444)
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue$$ExternalSyntheticLambda0.call(Unknown Source:2)
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:330)
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$$ExternalSyntheticLambda2.run(Unknown Source:4)
10041 10041 E detox   :      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
10041 10041 E detox   :      at java.util.concurrent.FutureTask.run(FutureTask.java:264)
10041 10041 E detox   :      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
10041 10041 E detox   :      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
10041 10041 E detox   :      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
10041 10041 E detox   :      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:235)
10041 10041 E detox   :      at java.lang.Thread.run(Thread.java:1012)