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

喜你入骨 提交于 2019-11-26 23:36:41

问题


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:

And this is the source code of AppCompatActivity


回答1:


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'



回答2:


It's your core library. Also general rule of thumb for production code, try to avoid using alpha. Update the following libraries and you should be fine.

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'


来源:https://stackoverflow.com/questions/55303033/androidx-appcompat-app-appcompatactivity-doesnt-implement-lifecycleowner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!