Kotlin-android: unresolved reference databinding

后端 未结 16 1028
借酒劲吻你
借酒劲吻你 2020-12-02 16:23

I have following fragment class written in Java using the new databinding library

import com.example.app.databinding.FragmentDataBdinding;

public class Data         


        
16条回答
  •  执笔经年
    2020-12-02 16:47

    Add following in you app build.gradle

    kapt "com.android.databinding:compiler:$android_plugin_version"
    apply plugin: 'kotlin-kapt' // This one at top where plugin belong to
    

    This will do the trick.

    $android_plugin_version is version of com.android.tools.build:gradle in application build.gradle

    Also, add this to your module build.gradle

    android { /// Existing Code kapt { generateStubs = true } }

提交回复
热议问题