I recently updated the Travis CI configuration for my Android application project (Android Gradle Plugin 7.0.3, targetSdk 30, JVM 11) to use the new command line tools. I have chosen system-images;android-19;google_apis;armeabi-v7a
to start an emulator to run the instrumentation tests. I am using androidx.test.espresso:espresso-core:3.4.0
.
The emulator boots and executes the instrumentation tests via connectedDebugAndroidTest
but all fail with the following error:
AboutActivityTest > renderBuildInformation[test(AVD) - 4.4.2] FAILED
java.lang.AssertionError: Activity never becomes requested state
"[DESTROYED, STARTED, RESUMED, CREATED]" (last lifecycle transition = "PRE_ON_CREATE")
at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)
...
Gradle then outputs:
Caused by: org.gradle.api.GradleException: There were failing tests. See the report
at: file:///home/travis/build/Umweltzone/Umweltzone/Umweltzone/build/reports/androidTests/connected/index.html
at com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask.doTaskAction(DeviceProviderInstrumentTestTask.java:388)
at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:63)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
...
Full build log:
The same tests successfully execute if I run them locally on a Pixel 2 device, Android 11 (SDK 30).
How can I fix the Travis CI / Android emulator configuration?
Related
- Activity never becomes requested state "[DESTROYED, RESUMED, STARTED, CREATED]" (last lifecycle transition = "PRE_ON_CREATE")
- AndroidX.Test ActivityScenario: java.lang.AssertionError: Activity never becomes requested state "[RESUMED]" (last lifecycle transition = "STOPPED")
- Android instrumented test throws exception: Activity never becomes requested state "[RESUMED, DESTROYED, STARTED, CREATED]"
- How do I fix this error java.lang.AssertionError: Activity never becomes requested state "[DESTROYED]" (last lifecycle transition = "RESUMED")