7

I'm getting a lot of errors with data binding errors after migrating to AndroidX (Refactor > Migrate to AndroidX).

error: cannot find symbol
      @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) {
                                                                ^
  symbol:   class DataBindingComponent
  location: class ActivityInfoBinding   

I'm using Android Studio 3.2 Beta 2

My dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.cardview:cardview:1.0.0-beta01'
    implementation 'com.google.android.material:material:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha1'
    implementation "com.squareup.retrofit2:retrofit:$versions.retrofit"
    implementation "com.squareup.retrofit2:converter-gson:$versions.retrofit"
    implementation 'androidx.room:room-runtime:2.0.0-beta01'
    kapt 'androidx.room:room-compiler:2.0.0-beta01'
    implementation "androidx.core:core-ktx:$versions.ktx"
    implementation 'androidx.lifecycle:lifecycle-runtime:2.0.0-beta01'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-beta01'
    kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0-beta01'
    implementation "me.tatarka.bindingcollectionadapter2:bindingcollectionadapter:$versions.binding_collection_adapter"
    implementation "me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-recyclerview:$versions.binding_collection_adapter"
    implementation "com.jakewharton.threetenabp:threetenabp:$versions.threetenabp"
    implementation "com.google.dagger:dagger:$versions.dagger"
    kapt "com.google.dagger:dagger-compiler:$versions.dagger"
    kapt "com.google.dagger:dagger-android-processor:$versions.dagger"
    implementation "com.google.dagger:dagger-android-support:$versions.dagger"
    implementation "com.airbnb.android:lottie:$versions.lottie"
    implementation "com.github.bumptech.glide:glide:$versions.glide"
    implementation "com.jakewharton.timber:timber:$versions.timber"
    implementation "com.crashlytics.sdk.android:crashlytics:$versions.crashlytics"
    implementation "com.google.firebase:firebase-core:$versions.firebase_core"

    testImplementation "junit:junit:$versions.junit"
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
} 
jakub
  • 3,576
  • 3
  • 29
  • 55
  • 1
    databinding is a curse in Android. – Sunny Jul 06 '18 at 06:30
  • 2
    I love android databinding itself, the code is so clean, but the tools make it so hard to work with :( – jakub Jul 06 '18 at 12:31
  • Did you try to rebuild and / or Invalidate Cache & Restart? There are newer version available, for example: androidx.appcompat:appcompat:1.0.0-rc02 you should update these. Can you show the whole class in which the error that you show occurs? – 476rick Sep 12 '18 at 11:45
  • @qbait yesterday found out, that there is an `androidx` data-binding compiler available (despite still experimental): https://stackoverflow.com/a/52489036/549372 – Martin Zeitler Sep 26 '18 at 02:49

2 Answers2

1

Updating to latest Android Studio and re-importing the project fixed my issue.

Sahil Gera
  • 478
  • 4
  • 10
0

To fix this issue I had to update all class names on layout files.

From:

<android.support.design.widget.CoordinatorLayout
<android.support.v7.widget.RecyclerView
...

to:

<androidx.core.widget.NestedScrollView
<androidx.coordinatorlayout.widget.CoordinatorLayout
...

After that, the data binding errors where gone.

I ran the migration tool, but it didn't fixed the class names on layout xmls, sad!

Soulblighter
  • 61
  • 1
  • 5