How to disable the generating of synthetic view properties by the Kotlin Android extensions plugin

↘锁芯ラ 提交于 2019-12-23 08:47:16

问题


The Kotlin Android Extensions plugin generates static properties for each view with an ID from my app layout files, as it is described in the documentation.

I would like to disable this feature, because we use DataBinding instead of the Kotlin synthetic view properties, and sometimes I import them by accident; also it adds extra build overhead for something we don't use.

Disabling the Android extensions plugin is not possible, because we use the Parcelize feature which is done by the same plugin.


回答1:


There is a features property in the androidExtensions DSL that allows you to provide a list of features to enable. Currently, there is only two available, parcelize and views. To disable synthetic view properties, add this to your build.gradle:

androidExtensions {
    features = ["parcelize"]
}

Source: https://github.com/JetBrains/kotlin/blob/6bef27e1e889b17ae84dd2ff99881727f13ac3e5/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt#L57



来源:https://stackoverflow.com/questions/54184154/how-to-disable-the-generating-of-synthetic-view-properties-by-the-kotlin-android

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