我正面临这种幻像错误。我已经尝试了多种方法来解决此问题,但是所有方法均无效。我不知道是什么导致了这个问题。这是我在构建日志中的错误:
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
这是我的项目级别gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
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
}
这是我的应用级别gradle:
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上创建的变量时,它说:“无法访问类,请检查模块类路径中是否缺少依赖项或发生冲突”。 / p>
请帮助我。