appium-espresso-driver: Can't make Appium work with Compose 1.2.0 - java.lang.AbstractMethodError: abstract method "kotlin.coroutines.CoroutineContext$Key androidx.compose.ui.platform.InfiniteAnimationPolicy.getKey()"

I’m using latest beta versions of appium (Appium v2.0.0-beta.42) and espresso driver, but I can’t make it work with compose app. I’ve tried even on empty compose Hello world project generated by Android studio (using compose version 1.2.0), but the appium still throws this error:

[debug] [EspressoDriver@d452 (d7e46f24)] [Instrumentation] io.appium.espressoserver.EspressoServerRunnerTest: [debug] [EspressoDriver@d452 (d7e46f24)] [Instrumentation] Error in startEspressoServer(io.appium.espressoserver.EspressoServerRunnerTest): [debug] [EspressoDriver@d452 (d7e46f24)] java.lang.AbstractMethodError: abstract method "kotlin.coroutines.CoroutineContext$Key androidx.compose.ui.platform.InfiniteAnimationPolicy.getKey()" [debug] [EspressoDriver@d452 (d7e46f24)] at kotlin.coroutines.CoroutineContext$plus$1.invoke(CoroutineContext.kt:33) [debug] [EspressoDriver@d452 (d7e46f24)] at kotlin.coroutines.CoroutineContext$plus$1.invoke(CoroutineContext.kt:32) [debug] [EspressoDriver@d452 (d7e46f24)] at kotlin.coroutines.CoroutineContext$Element$DefaultImpls.fold(CoroutineContext.kt:70) [debug] [EspressoDriver@d452 (d7e46f24)] at androidx.compose.ui.platform.InfiniteAnimationPolicy$DefaultImpls.fold(InfiniteAnimationPolicy.kt:36) [debug] [EspressoDriver@d452 (d7e46f24)] at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$infiniteAnimationPolicy$1.fold(ComposeUiTest.android.kt:239) [debug] [EspressoDriver@d452 (d7e46f24)] at kotlin.coroutines.CoroutineContext$DefaultImpls.plus(CoroutineContext.kt:32) [debug] [EspressoDriver@d452 (d7e46f24)] at kotlin.coroutines.CombinedContext.plus(CoroutineContextImpl.kt:111) [debug] [EspressoDriver@d452 (d7e46f24)] at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.<init>(ComposeUiTest.android.kt:248) [debug] [EspressoDriver@d452 (d7e46f24)] at androidx.compose.ui.test.junit4.AndroidComposeTestRule$special$$inlined$AndroidComposeUiTestEnvironment$1.<init>(ComposeUiTest.android.kt:203) [debug] [EspressoDriver@d452 (d7e46f24)] at androidx.compose.ui.test.junit4.AndroidComposeTestRule.<init>(AndroidComposeTestRule.android.kt:212) [debug] [EspressoDriver@d452 (d7e46f24)] at io.appium.espressoserver.EspressoServerRunnerTest.<init>(EspressoServerRunnerTest.kt:45)

Did anyone make appium espresso work with Compose?

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 10
  • Comments: 20 (8 by maintainers)

Most upvoted comments

The build itself seems ok, the above behavior is expected

I fixed this by forcing androidx.compose.ui to 1.2.1, looks like there was a dependency conflict between testing and runtime deps

Tried a bit last night. Still getting a weird error, so need to take a look further though. It seems like the compose also has complicated dependencies… (based on https://github.com/toantk238/Test-Appium-Espresso-Driver)

1) startEspressoServer(io.appium.espressoserver.EspressoServerRunnerTest)
java.lang.IllegalStateException: The application under test must require android.permission.INTERNET permission in its manifest
	at io.appium.espressoserver.lib.http.Server.start(Server.kt:93)
	at io.appium.espressoserver.EspressoServerRunnerTest.startEspressoServer(EspressoServerRunnerTest.kt:67)
	... 53 trimmed
Caused by: java.net.BindException: bind failed: EADDRINUSE (Address already in use)
	at libcore.io.IoBridge.bind(IoBridge.java:108)
	at java.net.PlainSocketImpl.socketBind(PlainSocketImpl.java:162)
	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:427)
	at java.net.ServerSocket.bind(ServerSocket.java:377)
	at java.net.ServerSocket.bind(ServerSocket.java:331)
	at fi.iki.elonen.NanoHTTPD$ServerRunnable.run(NanoHTTPD.java:1761)
	at java.lang.Thread.run(Thread.java:923)
Caused by: android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
	at libcore.io.Linux.bind(Native Method)
	at libcore.io.ForwardingOs.bind(ForwardingOs.java:74)
	at libcore.io.ForwardingOs.bind(ForwardingOs.java:74)
	at libcore.io.IoBridge.bind(IoBridge.java:104)
	... 6 more

FAILURES!!!
Tests run: 1,  Failures: 1


(headspin) kazu$ git diff
diff --git a/android_app/app/src/main/AndroidManifest.xml b/android_app/app/src/main/AndroidManifest.xml
index 8d1f774..aa5abe7 100644
--- a/android_app/app/src/main/AndroidManifest.xml
+++ b/android_app/app/src/main/AndroidManifest.xml
@@ -2,6 +2,9 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools">

+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+
     <application
         android:allowBackup="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
diff --git a/android_test/app/build.gradle.kts b/android_test/app/build.gradle.kts
index 9b757ec..c445c57 100644
--- a/android_test/app/build.gradle.kts
+++ b/android_test/app/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
 }

 android {
-    compileSdk = getIntProperty("appiumCompileSdk", 32)
+    compileSdk = getIntProperty("appiumCompileSdk", 33)
     buildToolsVersion = getStringProperty("appiumBuildTools", "32.0.0")
     defaultConfig {
         // <instrumentation android:targetPackage=""/>
@@ -48,6 +48,14 @@ android {
             keyPassword = "android"
         }
     }

     compileOptions {
         sourceCompatibility = JavaVersion.VERSION_11
@@ -110,15 +118,8 @@ dependencies {
     androidTestImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
     androidTestImplementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
     androidTestImplementation("androidx.compose.ui:ui-test:${composeVersion}")
-    androidTestImplementation("androidx.compose.ui:ui-test-junit4:${composeVersion}") {
-        isTransitive = false
-    }
-
-    // additionalAndroidTestDependencies placeholder (don't change or delete this line)
-    androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
-    androidTestImplementation("androidx.compose.ui:ui-test-manifest:1.2.1")
-    androidTestImplementation("androidx.test.ext:junit:1.1.3")
-    androidTestImplementation("com.google.truth:truth:1.1.3")
+    androidTestImplementation("androidx.compose.ui:ui-test-junit4:${composeVersion}")
+    androidTestImplementation("androidx.compose.ui:ui-test-manifest:${composeVersion}")
 }

 configurations.all {
@@ -141,7 +142,7 @@ object Version {
     const val gson = "2.9.0"
     const val uia = "2.2.0"
     const val nanohttpd = "2.3.1"
-    const val annotation = "1.3.0"
+    const val annotation = "1.2.0"
     const val mockito = "4.0.0"
     const val robolectric = "4.5.1"
     const val junit = "4.13.2"
diff --git a/test.sh b/test.sh
index 60daf8c..6149578 100755

@rock-tran unfortunately we still didn’t manage to fix this issue. We are just trying different versions of appium driver (beta, rc) and some it works on some simple apps, but so far it never worked on the app we want to test.

Thanks for posting sample project, it would be really nice if @KazuCocoa came up with something

Let me take a look by finding a chance