Suman
Suman

Reputation: 1313

java.lang.NoSuchMethodError: No super method

Trying to use CameraX in Android.I am using code link .But i am facing Error
java.lang.NoSuchMethodError: No super method getLifecycle()Landroidx/lifecycle/Lifecycle; in class Landroidx/core/app/ComponentActivity; or its super classes

Error image

Upvotes: 2

Views: 1679

Answers (3)

Jaydeep Khambhayta
Jaydeep Khambhayta

Reputation: 5349

Add in build.gradle of app module

android { 

   compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

Upvotes: 0

Soumen Das
Soumen Das

Reputation: 1302

Please update Android AppCompat Library V7 See latest version 1.1.0-rc01 but you are using 1.0.2 Please replace this line in build.gradle

implementation 'androidx.appcompat:appcompat:1.0.2'

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'

You will find updated dependencies from the below link. https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google

Upvotes: 2

sanoJ
sanoJ

Reputation: 3128

The problem is in the appcompact dependency. If you check the source code of the version you are using 1.0.2, there is no super method in the ComponentActivity class and the FragmentActivity is trying to call that method.

To fix this you need to upgrade the version to 1.1.0-rc01. In this version FragmentActivity use a LifecycleRegistry to get the LifeCycle

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'

Upvotes: 2

Related Questions