gpt4 book ai didi

android - 找不到类 databinding.FragmentBinding

转载 作者:行者123 更新时间:2023-11-29 02:39:55 25 4
gpt4 key购买 nike

我试图在我的 fragment 中使用数据绑定(bind),但在运行时出现以下错误:

Could not find class 'com.example.databinding.FragmentUpSellBinding', referenced from method com.example.UpSellFragment.onCreateView

结果为:

FATAL EXCEPTION: main Process: nl.anwb.fietsen.debug, PID: 5563                                                                     
java.lang.IllegalStateException: DataBindingUtil.inflate(…r,
false) must not be null`

我的 build.gradle 看起来像这样:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
dataBinding {
enabled = true
}
}
kapt {
generateStubs = true
}

dependencies {
kapt 'com.android.databinding:compiler:3.0.0-alpha4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

主要的buid.gradle

buildscript {
ext.kotlin_version = '1.1.2-4'
ext{
supportLibraryVersion = '25.3.1'
}
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

有谁知道我该如何解决这个问题?

最佳答案

你不需要 build.gradle

    dataBinding {
enabled = true
}

删除并尝试

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'


kapt {
generateStubs = true
}

dependencies {
kapt 'com.android.databinding:compiler:3.0.0-alpha4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

并将您的 Kotlin 更新为

ext.kotlin_version = '1.1.3-2'

关于android - 找不到类 databinding.FragmentBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44947721/

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