gpt4 book ai didi

Android - Kotlin - 找不到符号 DataBindingComponent

转载 作者:行者123 更新时间:2023-12-04 23:38:06 28 4
gpt4 key购买 nike

我正面临这种幻像错误。我已经尝试了很多方法来解决这个问题,但没有任何效果。我不知道是什么产生了这个问题。这是我在构建日志中的错误:

e: /Users/galihlarasprakoso/Projects/Android/surat-kaleng/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/galihlprakoso/com/SuratKaleng/databinding/ActivityLoginBinding.java:17: error: cannot find symbol
protected ActivityLoginBinding(DataBindingComponent _bindingComponent, View _root,
^
symbol: class DataBindingComponent
location: class ActivityLoginBinding
e: /Users/galihlarasprakoso/Projects/Android/surat-kaleng/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/galihlprakoso/com/SuratKaleng/databinding/ActivityLoginBinding.java:31: error: cannot find symbol
@Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityLoginBinding
e: /Users/galihlarasprakoso/Projects/Android/surat-kaleng/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/galihlprakoso/com/SuratKaleng/databinding/ActivityLoginBinding.java:42: error: cannot find symbol
@Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityLoginBinding
e: /Users/galihlarasprakoso/Projects/Android/surat-kaleng/app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/galihlprakoso/com/SuratKaleng/databinding/ActivityLoginBinding.java:51: error: cannot find symbol
@Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityLoginBinding
e: [kapt] An exception occurred: java.lang.IllegalArgumentException: couldn't make a guess for galihlprakoso.com.SuratKaleng.databinding.ActivityLoginBindingImpl
这是我的项目级别 build.gradle.kts文件:
buildscript {
ext.kotlin_version = '1.2.71'
ext.dagger_version = '2.16'
ext.glide_version = '4.8.0'
ext.retrofit_version = '2.4.0'
ext.rxandroid_version = '2.1.0'
ext.rxjava_version = '2.2.2'
ext.support_version = '28.0.0'

repositories {
google()
jcenter()
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的应用级别 build.gradle.kts文件:
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-kapt'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId "galihlprakoso.com.SuratKaleng"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.support') {
details.useVersion "$support_version"
}
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//noinspection GradleCompatible
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"

//Dagger
implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"

//Glide
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

//Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"

//RXJava
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"

//Material Dialog
implementation 'com.afollestad.material-dialogs:core:2.0.0-beta2'

//Firebase
implementation 'com.google.firebase:firebase-core:16.0.3'

//Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'


configurations {
all*.exclude group: 'com.android.support', module: 'versionedparcelable'
}

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'

}

apply plugin: 'com.google.gms.google-services'
我不知道出了什么问题,但是当我尝试通过 binding.name_of_variable 访问我在 xml 中创建的变量时,它说: cannot access class check, your module classpath for missing or conflicting dependencies .

最佳答案

在 Android Studio 中尝试 Invalidate Caches/Restart..。
选择并单击Files->Invalidate Caches/Restart.. .
enter image description here
这将重新生成所需的。

关于Android - Kotlin - 找不到符号 DataBindingComponent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52565776/

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