BabyishTank
BabyishTank

Reputation: 1482

Espresso UI Test Cancelled with no error message

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?

Upvotes: 17

Views: 4379

Answers (2)

Lee Hounshell
Lee Hounshell

Reputation: 862

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.

Upvotes: 6

B3n
B3n

Reputation: 583

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!

Upvotes: 4

Related Questions