首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未解决的参考资料: Android多模块项目中的buildFeatures

未解决的参考资料: Android多模块项目中的buildFeatures
EN

Stack Overflow用户
提问于 2021-12-17 21:21:46
回答 1查看 237关注 0票数 2

在一个多模块项目中,我有以下设置:

  • android studio = 4.1.3
  • AGP = "4.1.3"
  • kotlin gradle plugin =“1.4.32”
  • 使用gradle.kts对我的所有gradle构建文件

在我的(应用)模块build.gradle.kts中,我启用了DataBinding和ViewBinding,一切都很好:-

代码语言:javascript
运行
复制
android{

    /* compileSdkVersion, buildToolsVersion etc...*/

     buildFeatures {
        dataBinding = true
        viewBinding = true
    }

}

我在buildSrc目录中使用一个常见的buildSrc类是将依赖项注入到模块中,还使用buildSrc目录中的Plugins.kt类来提供诸如"com.android.application“和"kapt”等插件。所有模块。

在我的:modules:rxandroid中,build.gradle.kts如下所示:

代码语言:javascript
运行
复制
plugins {
    /* defined in Plugins.kt*/
    androidLibrary()
    kotlinAndroid()
    kotlinKapt()

}
android {

    compileSdkVersion(AndroidSDK.compileSdk)
    buildToolsVersion(AndroidSDK.buildTools)

    defaultConfig {
        minSdkVersion(DefaultConfig.minSdk)
        targetSdkVersion(DefaultConfig.targetSdk)

    }

    /* 
        compilation error kicks in here, if the below block is removed eveyrthing works fine 
        but of ocurs i can't used either ViewBinding or DataBinding

    */
     buildFeatures {
        dataBinding = true
        viewBinding = true
    }


    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    // For Kotlin projects
    kotlinOptions {
        jvmTarget = "1.8"
    }

}

dependencies {

    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
    testImplementation(TestLibs.junit)

    /* defined in Dependencies.kt*/
    androidTestImplementation(TestLibs.runner)
    androidTestImplementation(TestLibs.espresso)

    implementation (KotlinLibs.kotlin_lib)
    implementation (KotlinLibs.kotlin_coroutines_core)
    implementation (KotlinLibs.kotlin_coroutine_android)
    implementation (KotlinLibs.kotlin_viewmodel_ktx)

    implementation (AndroidX.android_app_compat)
    implementation (AndroidX.android_constrain_layout)
    implementation (AndroidX.android_recyclerview)
    implementation (AndroidX.android_lifecycle_extensions)
    implementation (AndroidX.android_core_ktx)
    implementation (AndroidX.lifecycle_runtime_ktx)

    ...

}

生成项目时,将向控制台日志抛出折叠错误消息:

代码语言:javascript
运行
复制
Unresolved reference: buildFeatures

关于细节的截图是:-

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70399014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档