【发布时间】:2021-07-31 11:44:24
【问题描述】:
我正在尝试将数据绑定添加到我的应用程序。 但是我启用数据绑定后得到的错误是: 没有方法签名:build_9rfemhg4a5yc2kwb7aemx3270.android() 适用于参数类型:(build_9rfemhg4a5yc2kwb7aemx3270$_run_closure1) 值:[build_9rfemhg4a5yc2kwb7aemx3270$_run_closure1@6e3b0699]
导致错误的部分是:
databinding {
enabled = true
}
删除这部分会导致 gradle 正确构建。但是这样我就不能添加数据绑定了。
构建等级是:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.aboutme"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard- rules.pro'
}
}
databinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
【问题讨论】:
标签: android android-studio gradle data-binding