gpt4 book ai didi

android - 找不到 Gradle DSL 方法 : 'dataBinding()'

转载 作者:行者123 更新时间:2023-11-29 16:30:28 25 4
gpt4 key购买 nike

我是 Android 新手。在这里,我试图将数据绑定(bind)添加到我的 android 应用程序,因为我启用了到真正的应用程序内级别 gradle 文件的数据绑定(bind),但问题是它没有同步,它会给出这样的错误。

Gradle DSL method not found: 'dataBinding()'
Possible causes:
The project 'TriviaApp' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project

The project 'TriviaApp' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file

The build file may be missing a Gradle plugin.
Apply Gradle plugin

this is My app level gradle file code

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.triviaapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

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

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

任何人都可以帮我弄清楚我做错了什么并帮助我解决这个问题。

最佳答案

你应该使用

dataBinding {
enabled = true
}

确保你的build.gradle

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

allprojects {
repositories {
jcenter()
}
}

关于android - 找不到 Gradle DSL 方法 : 'dataBinding()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56471794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com