当前位置:网站首页>Databinding exception of kotlin

Databinding exception of kotlin

2022-07-07 07:07:00 Dream of changing life

I'm trying it out recently Kotlin +JetPack Component development project , I met a strange problem , Just trying Databinding When , When compiling a file , There is no mistake , But there will be BR File error . The principle of checking the official website is Kotlin In the use of Databinding When , Need configuration kapt plug-in unit .

Error:(6, 26) Unresolved reference: databinding

terms of settlement :
1、project build.gradle Middle configuration :

buildscript {
    ext.kotlin_version ='1.7.0'
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.2"
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://jitpack.io' }
    }
}

// The core :
    ext.kotlin_version ='1.7.0'
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0"

2、app build.gradle Middle configuration :


apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

kapt {
    generateStubs = true
}
	

Fix up the work , If you have any questions, please leave a message ~

原网站

版权声明
本文为[Dream of changing life]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070214222282.html