Error launching Jetpack Compose Android App using espresso driver

I plan on using Appium 2.0 in conjunction with the espresso driver in order to be able to test a UI built with Jetpack Compose. The app starts fine when using UIAutomator2 driver. However when using the espresso driver the app briefly launches then crashes with the error below. My developer has made some changes to the app in the hope of fixing but to no avail. Has anybody experienced anything similar or have any idea what the issue could be?

[debug] [Espresso] [Instrumentation] Process crashed while executing startEspressoServer(io.appium.espressoserver.EspressoServerRunnerTest):
[debug] [Espresso] java.lang.NoSuchMethodError: No virtual method getSetViewConfiguration()Lkotlin/jvm/functions/Function2; in class Landroidx/compose/ui/node/ComposeUiNode$Companion; or its super classes (declaration of ‘androidx.compose.ui.node.ComposeUiNode$Companion’ appears in /data/app/io.appium.espressoserver.test-bvOHEnT8MR0fRd3J2_1Kpg==/base.apk)
[debug] [Espresso] at myapp.view.AJSComposeFragment$onCreateView$1$1$1$1$1$1.invoke(AJSComposeFragment.kt:138)
[debug] [Espresso] at myapp.view.AJSComposeFragment$onCreateView$1$1$1$1$1$1.invoke(AJSComposeFragment.kt:58)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
[debug] [Espresso] at myapp.view.AJSThemeKt$AJSThemeSwitcher$2.invoke(AJSTheme.kt:152)
[debug] [Espresso] at myapp.view.AJSThemeKt$AJSThemeSwitcher$2.invoke(AJSTheme.kt:151)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
[debug] [Espresso] at myapp.view.AJSThemeKt$AJSTheme$1$1.invoke(AJSTheme.kt:131)
[debug] [Espresso] at myapp.view.AJSThemeKt$AJSTheme$1$1.invoke(AJSTheme.kt:130)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
[debug] [Espresso] at androidx.compose.material.MaterialTheme_androidKt.PlatformMaterialTheme(MaterialTheme.android.kt:23)
[debug] [Espresso] at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:82)
[debug] [Espresso] at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:81)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
[debug] [Espresso] at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
[debug] [Espresso] at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:265)
[debug] [Espresso] at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
[debug] [Espresso] at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
[debug] [Espresso] at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
[debug] [Espresso] at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215)
[debug] [Espresso] at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:72)

Most likely you need to customise the list of additional dependencies. Check https://github.com/appium/appium-espresso-driver/issues?q=is%3Aissue+is%3Aopen+"NoSuchMethodError" for more details

1 Like

Thank you for pointing me to that thread. It looks like that is indeed my problem. I’m not quite sure what it means though to “Upgrading Compose version to 1.1.0”. Does this mean to upgrade the version in the app I’m testing? That is already using 1.1.0. Or does it mean upgrade Compose version for the espresso driver? If so I can’t find anywhere to set the Compose version for Espresso.