error: cannot find symbol class DataBindingComponent

I downloaded an Android project, but I am getting this error:

Error:(42, 42) error: cannot find symbol class DataBindingComponent

Sample Import:

import android.databinding.DataBindingComponent; // no code-time error
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;

Sample Usage:

public FragmentFantasyPointsSingleBinding(DataBindingComponent bindingComponent, View root) {
        super(bindingComponent, root, 0);
        Object[] bindings = ViewDataBinding.mapBindings(bindingComponent, root, 4, sIncludes, sViewsWithIds);
        this.animationView = (LottieAnimationView) bindings[3];
        this.mboundView0 = (FrameLayout) bindings[0];
        this.mboundView0.setTag(null);
        this.progressView = (LinearLayout) bindings[2];
        this.recyclerView = (RecyclerView) bindings[1];
        setRootTag(root);
        invalidateAll();
    }

There is no error on code-time, but on compile-time I get the error that I mentioned.

When I try to go to definition on Android Studio, I can't.

App level build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.esports.flank"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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'
    compile 'com.android.support:support-annotations:26.1.0'
    compile "com.android.support:appcompat-v7:26.1.0"
    compile "com.android.support:recyclerview-v7:26.1.0"
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    compile('com.twitter.sdk.android:twitter:3.3.0@aar') {
        transitive = true
    }
    compile 'com.microsoft.azure:azure-mobile-android:3.4.0@aar'
    implementation 'com.airbnb.android:lottie:2.5.5'
    compile 'com.github.ybq:Android-SpinKit:1.1.0'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.romandanylyk:pageindicatorview:1.0.1@aar'
    api 'com.google.guava:guava:26.0-android'
    compile 'com.android.support:design:26.1.0'
    implementation 'com.wajahatkarim3.EasyFlipView:EasyFlipView:2.1.0'
}

I tried cleaning and rebuilding project, no luck yet.

Thanks for help.

Upvotes: 6

Views: 11336

Answers (2)

Jeff
Jeff

Reputation: 471

In my case the cause of the problem was that I moved a ViewModel from its original package "directory" to a new one I created to clean up my project. I also had a few other errors.

I had clicked "Make Project" repeatedly to locate import problems until they were all cleaned up, but that did not find the remaining errors in the relevant XML files that I found using Windows GREP.

I opened the associated XML files and found that the variable was still referring to the original path (note that the "<" and ">" are not shown because I don't know how to escape them):

variable name="viewModel" type="original.project.path.name"

I changed it to:

variable name="viewModel" type="new.project.path.name"

This fixed my version of this problem.

Upvotes: 0

cora32
cora32

Reputation: 402

This answer helped me in a similar case: https://stackoverflow.com/a/52550118/8655667

  1. Add lines android.enableExperimentalFeatureDatabinding=true and android.databinding.enableV2=false to gradle.properties
  2. Sync project
  3. Build -> Clean Project
  4. Build -> Rebuild Project

After rebuild it should give you the actual compilation failure reason.

Upvotes: 16

Related Questions