12

I'm facing this kind of phantom error. I've tried many ways to resolve this problem but nothing works. I don't know what produces this issue. This is my error in Build Log :

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

This is my project level build.gradle.kts file:

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
}

This is my app level build.gradle.kts file:

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'

I don't know what's wrong, but when I try to access the variable that I've created in xml via binding.name_of_variable, it says: cannot access class check, your module classpath for missing or conflicting dependencies.

Adinia
  • 3,722
  • 5
  • 40
  • 58
Galih laras prakoso
  • 689
  • 2
  • 7
  • 22
  • Have you tried **Rebuilding Project** ? – Jeel Vankhede Sep 29 '18 at 06:52
  • sure. I have try that. – Galih laras prakoso Sep 29 '18 at 07:23
  • 2
    Show your LoginActivity, as it has components in it that are not compiling (both the code and the xml please) – Sam Oct 03 '18 at 13:41
  • Did you find any solution on this? – jayellos Mar 18 '19 at 06:22
  • This looks like you have a syntax error or a definition missing somewhere (possibly your layout files) which causes your Databinding classes to fail compiling. Usually you can find the error buried at the top of the stacktrace. Alternatively you should pinpoint after which change this started happening - after creating a new layout file maybe? Or it could be new dependency injection - then check that file for errors. – Bjelis Apr 12 '19 at 11:54
  • 1
    i have try many methods. but then fixed by using the exact gradle version. trying to invalidate cache and restart. clean and rebuild. then suddenly fixed. dont know the exact solution of this problem. thanks for the responses all. – Galih laras prakoso May 19 '19 at 15:28

2 Answers2

1

Try Invalidate Caches/Restart.. in Android Studio.

Select and click Files->Invalidate Caches/Restart.. .

enter image description here

This will regenerate the required ones.

Sayooj
  • 766
  • 5
  • 23
0

You need to regenerate generated classes. To do this in android studio: Build->Clean Project after that Build->Rebuild Project or just run project. In terminal (on project root) : ./gradlew clean && ./gradlew build