Unresolved reference for synthetic view when layout is in library module

前端 未结 10 2101
醉梦人生
醉梦人生 2020-12-12 21:37

using Kotlin 1.20.20 (not that it matters, older versions behaves the same)

When layout is in separate library module Android Studio has no problem finding and refer

10条回答
  •  不思量自难忘°
    2020-12-12 21:56

    The solution is far simpler than imagined, Kotlin synthetic sugars are a part of Kotlin Android Extensions and you just have to apply the plugin manually (Android Studio applies this automatically only to application modules):

    Add the following to your library / feature module's build Gradle:

    apply plugin: 'kotlin-android-extensions'
    

    Now enjoy Kotlin synthetic sugars in your Kotlin code! ;)

提交回复
热议问题