Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

androidx.appcompat.app.AppCompatActivity doesn't implement LifecycleOwner

I know looks like some stupid error, but I cannot find it. In my project I have access to LifecycleOwner from my Fragments but not from Activity.

Here is my build.gradle

implementation project(':domain')
implementation project(':data')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

// Koin for Android
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-androidx-viewmodel:$koin_version"

// Anko
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation "org.jetbrains.anko:anko-sdk15-listeners:$anko_version"

//Architecture components
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

Here is the Activity code: enter image description here

And this is the source code of AppCompatActivity enter image description here

like image 638
Roman Nazarevych Avatar asked Mar 22 '19 15:03

Roman Nazarevych


Video Answer


1 Answers

As per this issue, this is a known issue if you use core-ktx:1.1.0 and appcompat:1.0.2, mixing alpha versions with stable releases. Upgrade to appcompat:1.1.0-alpha03 to fix the issue:

implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
like image 51
ianhanniballake Avatar answered Nov 03 '22 01:11

ianhanniballake