我使用的是Android 4.0.1版本。
当我添加viewBinding时,会出现一个错误。
当我在gradle中添加viewBinding时出错。
buildFeatures {
viewBinding = true
}build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "1.2.0"
resValue("string", "growingio_project_id", "8979dc98cc52320f")
resValue("string", "growingio_url_scheme", "growing.1f3e3791e1d6aee5")
}
compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibilityVersion
targetCompatibility rootProject.ext.targetCompatibilityVersion
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: "*.jar")
implementation deps.swipeRevealLayout
implementation deps.glide
implementation deps.growingio
implementation(deps.rxbus) {
exclude group: 'com.jakewharton.timber', module: 'timber'
}
implementation deps.androidasync
implementation deps.timber
}错误:
无法为参数build_6zjavhoqnf2k7dfs2qrq542f3$_run_closure1$_closure5@6cd00094在com.android.build.gradle.internal.dsl.BaseAppModuleExtension.类型的对象上找到方法buildFeatures()
为什么会出现这个错误?
如何解决这个错误?
发布于 2020-07-18 10:18:53
要在您的buildFeatures中使用build.gradle,您必须使用android gradle插件4.0.x
buildscript {
//..
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
//....
}
}然后你可以使用:
android {
//...
buildFeatures {
viewBinding true
}
}如果您正在使用android插件3.6,您可以使用:
android{
//....
viewBinding {
enabled = true
}
}发布于 2020-07-17 12:13:33
发布于 2020-07-17 10:44:46
尝试添加"dataBinding = true“并同步项目
buildFeatures{
dataBinding = true
viewBinding = true
}https://stackoverflow.com/questions/62951769
复制相似问题