首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >运行指令插入测试时,Cloud Firestore (22.1.0)出现内部错误

运行指令插入测试时,Cloud Firestore (22.1.0)出现内部错误
EN

Stack Overflow用户
提问于 2021-02-24 01:48:40
回答 1查看 567关注 0票数 3

我收到一条来自Cloud Firestore的内部错误消息。当我运行此测试时,应用程序从Firebase获取项目列表。这需要一段时间。在此期间,测试将停止。

每个库都会更新到最新版本。这个SO thread没有给出一个令人满意的答案。只有在运行测试时才会出现错误,实际的App是正常的。

代码语言:javascript
运行
复制
@InternalCoroutinesApi
@ExperimentalCoroutinesApi
@RunWith(AndroidJUnit4::class)
class HomeTest {

    @get:Rule
    var reportHelper: ReportHelper? = Factory.getReportHelper()

    @get:Rule
    var activityRule = ActivityScenarioRule(MainActivity::class.java)

    // Executes tasks in a synchronous [TaskScheduler]
    @get:Rule
    var syncTaskExecutorRule = SyncTaskExecutorRule()

    @Before
    fun goToHomeScreen() {
        onView(withId(R.id.navigation_home)).perform(ViewActions.click())
    }

    @Test
    fun scrollToNextVideo() {
        onView(withId(R.id.recycler)).perform(swipeUp())
    }

    @After
    fun TearDown() {
        reportHelper?.label("Stopping App")
    }
}

build.gradle (应用程序级别):

代码语言:javascript
运行
复制
android {
    configurations.all() { configuration ->
//    exclude group: "com.google.protobuf", module: "protobuf-javalite"

       exclude group: "com.google.protobuf", module: "protobuf-java"
//    exclude group: "io.grpc", module: "grpc-protobuf-lite" // tried this, but App fails to compile
}
dependencies {
    implementation "com.google.firebase:firebase-firestore-ktx:23.0.0"
    implementation "com.google.firebase:firebase-database-ktx:20.0.0"
    implementation "com.google.firebase:firebase-storage-ktx:20.0.0"
    implementation "com.firebaseui:firebase-ui-storage:4.3.2"
}

这是我的dependencies.txt

堆栈跟踪:

代码语言:javascript
运行
复制
Testing started at 18:40 ...

02/23 18:40:39: Launching 'HomeTest' on Samsung SM-A515F.
App restarts successfully without requiring a re-install.
Running tests

$ adb shell am instrument -w -m  --no-window-animation  -e debug false -e class 'eu.theappfactory.someapp.data.ui.home.HomeTest' eu.theappfactory.someapp.acc.test/androidx.test.runner.AndroidJUnitRunner
Connected to process 981 on device 'samsung-sm_a515f-R58N52ZCJZL'.

Started running tests

java.lang.RuntimeException: Internal error in Cloud Firestore (22.1.0).
    at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:534)
    at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8167)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
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/eu.theappfactory.someapp.acc.test-K43eWkkKbA6iBOHgciWAfA==/base.apk)
    at com.google.firestore.v1.ListenRequest.<clinit>(ListenRequest.java:849)
    at com.google.firestore.v1.ListenRequest.getDefaultInstance(ListenRequest.java:854)
    at com.google.firestore.v1.FirestoreGrpc.getListenMethod(FirestoreGrpc.java:396)
    at com.google.firebase.firestore.remote.WatchStream.<init>(WatchStream.java:61)
    at com.google.firebase.firestore.remote.Datastore.createWatchStream(Datastore.java:115)
    at com.google.firebase.firestore.remote.RemoteStore.<init>(RemoteStore.java:167)
    at com.google.firebase.firestore.core.MemoryComponentProvider.createRemoteStore(MemoryComponentProvider.java:72)
    at com.google.firebase.firestore.core.ComponentProvider.initialize(ComponentProvider.java:135)
    at com.google.firebase.firestore.core.FirestoreClient.initialize(FirestoreClient.java:258)
    at com.google.firebase.firestore.core.FirestoreClient.lambda$new$0(FirestoreClient.java:105)
    at com.google.firebase.firestore.core.FirestoreClient$$Lambda$1.run(Unknown Source:8)
    at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$2(AsyncQueue.java:436)
    at com.google.firebase.firestore.util.AsyncQueue$$Lambda$2.call(Unknown Source:2)
    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:322)
    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$$Lambda$2.run(Unknown Source:4)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:229)
    at java.lang.Thread.run(Thread.java:919)

Test running failed: Process crashed.
Tests ran to completion.

tried this,不起作用。this also不起作用。

EN

Stack Overflow用户

发布于 2021-05-05 10:31:37

TL;DR:protobuf-javalite可能是您想要构建的基础。

这是一个known issue,它很可能是由build.gradle的某些部分引起的,而您已经隐瞒了这些部分。我所能说的是,排除模块protobuf-javalite会剥离静态方法registerDefaultInstance;因此,应该只排除protobuf-java

代码语言:javascript
运行
复制
configurations.all() { configuration ->
    // exclude group: "com.google.protobuf", module: "protobuf-javalite"
    exclude group: "com.google.protobuf", module: "protobuf-java"
}

使用Kotlin依赖可能也是有意义的,但这不应该是原因:

代码语言:javascript
运行
复制
implementation 'com.google.firebase:firebase-firestore-ktx:22.1.2'

要检查实际打包的内容:./gradlew :app:dependencies > dependencies.txt

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66338416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档