【问题标题】:Unresolved reference: binding - Kotlin Android未解决的参考:绑定 - Kotlin Android
【发布时间】:2020-12-26 21:16:48
【问题描述】:

我不断收到错误“未解析的引用:绑定”。有谁知道我错过了什么?我已经尝试更新所有内容。但是绑定不起作用。

Build.Gradle.(module.app):

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29



    defaultConfig {
        applicationId "com.example.madlevel1example"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        viewBinding = true}

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

【问题讨论】:

标签: android android-studio kotlin


【解决方案1】:

我建议你使用 dataBinding 而不是 viewBinding。 Altho viewBinding 的构建时间更短。数据绑定占了很大一部分。

参考此堆栈链接

https://stackoverflow.com/questions/58040778/android-difference-between-databinding-and-viewbinding#:~:text=1%20Answer&text=The%20main%20advantages%20of%20viewbinding,processors%20affecting%20databinding's%20build%20time.

【讨论】:

    猜你喜欢
    • 2016-01-14
    • 2020-01-18
    • 2021-11-02
    • 2019-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    相关资源
    最近更新 更多