Npm Appium server with Espresso driver: No static method lifecycleEventObserver
See original GitHub issueHello. I’m not able to start a test automation in Appium using Espresso driver. With UiAutomator2 it works fine. Appium server is giving me the following error: java.lang.NoSuchMethodError: No static method lifecycleEventObserver. full appium server log
The automation project was created in IntelliJ IDEA. It is in Kotlin \ Gradle, uses Appium lib 7.4.1 and server 1.19.1 (installed through npm). I’m on Windows 10. Android SDK Tools and Emulator are up to date. Java version is 8.
The .apk project was created in Android Studio. It is a fresh .apk project, created by Android Studio template. There’s nothing customized or external dependencies. Here’s its build.gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.sampleApp"
minSdkVersion 30
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// buildTypes {
// release {
// minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// }
// }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
More details are found here: https://discuss.appium.io/t/appium-server-1-19-1-still-getting-lifecycleeventobserver-error-when-using-espresso-driver/32569/9
It seems there are conflicting dependencies between Appium Espresso driver and the .apk. As a workaround, I was told to mess around with Espresso’s dependencies in Appium npm module, but I’m a little clueless about it. There’s nothing much on Google about this bug. I need help… thank you!
When using the Desktop Appium server (Appium Desktop), I get a different error: https://github.com/appium/appium-espresso-driver/issues/640
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
I have managed to fix my problem by adding this desired capability: “espressoBuildConfig”: “{ “additionalAppDependencies”: [ “com.google.android.material:material:1.0.0”, “androidx.lifecycle:lifecycle-extensions:2.1.0” ] }” }
The build config sounds reasonable, but to be honest I’m not sure how anybody can use the espresso driver with this bug? Does it only hit this code path under certain conditions? The default template seems broken to me.