question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Npm Appium server with Espresso driver: No static method lifecycleEventObserver

See original GitHub issue

Hello. 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:open
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
mihai169devcommented, Jan 15, 2021

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” ] }” }

8reactions
Redthcommented, Jan 8, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

still getting lifecycleEventObserver error when using Espresso ...
I'm stuck for days trying to simply launch an app using Espresso driver with Appium. I'm on a Kotlin \ Gradle project, using...
Read more >
appium-espresso-driver - npm
Start using appium-espresso-driver in your project by running `npm i appium-espresso-driver`. There are 12 other projects in the npm ...
Read more >
Testing Native Apps | Mendix Documentation
The Espresso driver requires you to install instrumentation in your app to ... we observed a No static method lifecycleEventObserver error.
Read more >
Using Espresso With Appium - HeadSpin
People assume Espresso is an alternative to Appium; ... will spin up an Appium server that knows about the most recent Espresso driver...
Read more >
Android - Jetpack - Make lazily created class lifecycle aware
I thought of caching the LifecyclerOwner in onCreate , but that means keeping reference to the View in a VM, which is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found