14

Here is the problem when I run my UI test. enter image description here

But the ExampleInstrumentedTest is working.

This is my test file, I already comment out everything, leaving an empty function


@RunWith(AndroidJUnit4ClassRunner::class)
class ExploreFragmentTest {

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

    @Test
    fun test_isSearchButtonDisplayed() {
        //onView(withId(R.id.btn_search)).check(matches(isDisplayed()))
    }
}

Here is my dependency in app/gradle

    // AndroidX Test - Instrumented testing
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'

how to see the actual error message???

Can we do better on the error feedback?

BabyishTank
  • 1,329
  • 3
  • 18
  • 39
  • 1
    It happens here too. Did you discover what it is? – kaneda Sep 03 '21 at 02:03
  • 2
    this mean the app crashed while running the test. In my case was segment analytics trying to make network call in the test environment. Poor error message. – BabyishTank Sep 03 '21 at 04:30
  • 1
    Thanks, that was very helpful. My case was the same as yours. Could just find out after looking at crashlytics. – kaneda Sep 03 '21 at 13:18

2 Answers2

6

for me this was caused by using an x86 emulator. when I switched to x86_64 the problem stopped for APIs 30 and below; however, I still have this issue using API 31.

Lee Hounshell
  • 842
  • 9
  • 10
4

I had the same error.

I used adb and logcat to view the logs: adb logcat

I found this error in my logs:

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/~~BuZ1RxiHRJybZNpyUcjGIw==/-xuI8WeeYUojtsn-ncVI-aw==/base.apk)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at com.google.firebase.perf.v1.ApplicationInfo.<clinit>(ApplicationInfo.java:1085)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at com.google.firebase.perf.v1.ApplicationInfo.newBuilder(ApplicationInfo.java:533)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at com.google.firebase.perf.transport.TransportManager.finishInitialization(TransportManager.java:226)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at com.google.firebase.perf.transport.TransportManager.syncInit(TransportManager.java:220)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at com.google.firebase.perf.transport.TransportManager.$r8$lambda$LuAwHBxy50Yf-ziHqcD54KjEPtk(Unknown Source:0)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda1.run(Unknown Source:2)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
01-30 08:23:34.286  5932  6012 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:920)

To fix that, I excluded protobuf-lite from androidx.test.espresso:espresso-contrib:3.4.0 in my build.gradle file:

androidTestImplementation ("androidx.test.espresso:espresso-contrib:3.4.0") {
    exclude module: "protobuf-lite"
}

And now my test works!

B3n
  • 536
  • 1
  • 3
  • 16