简体   繁体   中英

kotlin-android-extensions stop working if lifecycle-extensions is included in gradle

After adding the Android lifecycle component to my project with the following line: implementation("androidx.lifecycle:lifecycle-extensions:$lifecycleVersion") in my app's build.gradle.kts file all the import kotlinx.android.synthetic stop working, lifecycleVersion is defined as "2.0.0"

It gives me the following error in the places where I use the imported views. And the imports are marked as unused by the IDE

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:

I tried moving the source code from the main/java folder to a main/kotlin one after searching for a solution online but it didn't work.

It seems like the issue was that since the navigation dependencies must be (for now) in the android.arch distribution adding androidx dependencies messed with the project. The problem have been solved by replacing the previous conflicting dependency to:

implementation("android.arch.lifecycle:extensions:1.1.1")

It is curious that the only conflicting dependency was that one and not the others. But after changing all the dependencies to the android.arch distribution the problem have been solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM