Calas
Calas

Reputation: 73

Why am I getting Internal error in Cloud Firestore (24.1.2). In my Android app only when running an espresso test?

The app seems to be running fine, and the data loads to the application with no problem, but I am getting this error only when running a test to see if my match card for my dating app exists. I ran this same test with mock local data and had no issues. When I connect my app to firebase I get this error.

Caused by: java.lang.RuntimeException: Internal error in Cloud Firestore (24.1.2).

Here is the code for the test that I am running:

public void matchesCardExists(){
        onView(withId(R.id.name)).perform(replaceText("Bill"));
        onView(withId(R.id.email)).perform(replaceText("[email protected]"));
        onView(withId(R.id.user_name)).perform(replaceText("bigbill"));
        onView(withId(R.id.description)).perform(replaceText("This is a test"));
        onView(withId(R.id.occupation)).perform(replaceText("I work at test"));

        onView(withId(R.id.dateButton)).perform(click());

        onView(withClassName(Matchers.equalTo(DatePicker.class.getName())))
                .perform(PickerActions.setDate(2000, 2 + 1, 5));

        onView(withId(android.R.id.button1)).perform(click());

        onView(withId(R.id.submitButton)).perform(click());

        openActionBarOverflowOrOptionsMenu(ApplicationProvider.getApplicationContext());
        onView(withText("Matches")).perform(click());

        onView(isRoot()).perform(HelpersViewMatcher.waitView(withText("Cool Guy Mike"), 100000));

        onView(withRecyclerView(R.id.recycler_view).atPosition(0)).check(matches(hasDescendant(withText("Cool Guy Mike"))));

Basically it fills out a form to sign up and sends the user to a tabbed activity with a matches fragment. The matches fragment has cards loaded with data from the firestore. The test checks the card in the first position for the string "Cool Guy Mike".

Here is the stack trace from firebase.

java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at com.example.datingapp.RecyclerViewMatcher$1.matchesSafely(RecyclerViewMatcher.java:56)
at com.example.datingapp.RecyclerViewMatcher$1.matchesSafely(RecyclerViewMatcher.java:30)
at org.hamcrest.TypeSafeMatcher.matches(TypeSafeMatcher.java:67)
at androidx.test.espresso.base.ViewFinderImpl$MatcherPredicateAdapter.apply(ViewFinderImpl.java:1)
at androidx.test.espresso.core.internal.deps.guava.collect.Iterators$5.computeNext(Iterators.java:3)
at androidx.test.espresso.core.internal.deps.guava.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:2)
at androidx.test.espresso.core.internal.deps.guava.collect.AbstractIterator.hasNext(AbstractIterator.java:5)
at androidx.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:7)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:5)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Here is the error in Android Studio

androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 1082, 465 and precision: 16, 16' on view 'Animations or transitions are enabled on the target device.
For more info check: https://developer.android.com/training/testing/espresso/setup#set-up-environment

an instance of android.widget.TextView and view.getText() with or without transformation to match: is "Matches"'.
    at androidx.test.espresso.PerformException$Builder.build(PerformException.java:1)
    at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:9)
    at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:7)
    at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:8)
    at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:11)
    at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:4)
    at com.example.datingapp.MainActivityTest.matchesCardExists(MainActivityTest.java:265)
    ... 29 trimmed
Caused by: 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.-$$Lambda$AsyncQueue$jx84dqgUsF4ojecSMurRqFLFD1Y.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:14)
    at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:8)
    at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:1)
    at androidx.test.espresso.base.UiControllerImpl.loopMainThreadForAtLeast(UiControllerImpl.java:8)
    at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:6)
    at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:6)
    at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:2)
    at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:22)
    at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:1)
    at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:2)
    at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
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/com.example.datingapp.test-LB1xq3vHsZYBNdA8gmmVkQ==/base.apk)
    at com.google.firestore.v1.ListenRequest.<clinit>(ListenRequest.java:873)
    at com.google.firestore.v1.ListenRequest.getDefaultInstance(ListenRequest.java:878)
    at com.google.firestore.v1.FirestoreGrpc.getListenMethod(FirestoreGrpc.java:384)
    at com.google.firebase.firestore.remote.WatchStream.<init>(WatchStream.java:61)
    at com.google.firebase.firestore.remote.Datastore.createWatchStream(Datastore.java:131)
    at com.google.firebase.firestore.remote.RemoteStore.<init>(RemoteStore.java:167)
    at com.google.firebase.firestore.core.MemoryComponentProvider.createRemoteStore(MemoryComponentProvider.java:78)
    at com.google.firebase.firestore.core.ComponentProvider.initialize(ComponentProvider.java:143)
    at com.google.firebase.firestore.core.FirestoreClient.initialize(FirestoreClient.java:272)
    at com.google.firebase.firestore.core.FirestoreClient.lambda$new$0$FirestoreClient(FirestoreClient.java:109)
    at com.google.firebase.firestore.core.-$$Lambda$FirestoreClient$Eq-cAcb1C1mM4tyiJsLJXZ13tyU.run(Unknown Source:8)
    at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$2(AsyncQueue.java:441)
    at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$Y9GO7zO2DX6MzQJ5TbKtKW_NzO0.call(Unknown Source:2)
    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:327)
    at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$SynchronizedShutdownAwareExecutor$pKSAgg-ozJ8RbUveSl-44aUfFQw.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:234)
    at java.lang.Thread.run(Thread.java:919)

Upvotes: 1

Views: 1300

Answers (1)

Calas
Calas

Reputation: 73

It turns out that I had some outdated gradle dependencies. I am not exactly sure which ones it was but I changed my app gradle dependencies from:


    // Declare the dependency for the Firebase Authentication library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-auth'

    // Also declare the dependency for the Google Play services library and specify its version
    implementation 'com.google.android.gms:play-services-auth:20.2.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test:core:1.4.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.room:room-testing:2.4.2'
    annotationProcessor 'androidx.room:room-compiler:2.4.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.4.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    implementation platform('com.google.firebase:firebase-bom:30.0.0')

}

to this instead:

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation platform('com.google.firebase:firebase-bom:29.3.1')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-firestore:24.1.2'
    implementation 'androidx.room:room-runtime:2.4.2'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.4.0') {
        exclude module: "protobuf-lite"
    }
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'
    androidTestImplementation 'androidx.room:room-testing:2.4.2'
    annotationProcessor 'androidx.room:room-compiler:2.4.2'
}

This seems to have fixed the problem and my tests are now running perfectly.

Upvotes: 2

Related Questions