繁体   English   中英

Android 资源链接使用失败:buildFeatures {viewBinding = true}

[英]Android Resourcse linking Failed while using : buildFeatures {viewBinding = true}

今天入手一个android工作室后,遇到了一个奇怪的问题。 它在说

DSL 元素 'android.viewBinding.enabled' 已过时,已替换为 'android.buildFeatures.viewBinding'。

搜索了一下后我发现我必须使用

buildFeatures {viewBinding = true}

反而。 所以,我用上面的替换了 viewBinding{enabled=true} 在那之后,真正的问题开始了。 AAPT 无法再检测到我的可绘制对象。 这是我的构建脚本:

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

和 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.techtrixbd.RestaurantApp"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {viewBinding = true}
}

我不知道发生了什么事了。 任何建议都会有很大帮助。

我已经解决了这个问题。 我不得不将我的资源移动到 drawable-v24 文件夹。 而已。 但是,不要因为昨天一切正常而需要它。 也许更新与它有关。 我会寻找原因,如果我想出一些东西,我会发布。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM