databinding does not exist: How to solve it?

前端 未结 8 954
生来不讨喜
生来不讨喜 2021-01-01 20:37

I\'m working on an Android application with databinding but I\'ve always next error:

Error: Package my.package.databinding

8条回答
  •  囚心锁ツ
    2021-01-01 21:18

    I came across this issue in a project of 4 modules in Android Studio 2.3, it is what @F43nd1r indicated, but want to document what I did to resolve this in my case.

    One of the 4 modules had an older Android Support library in in the Gradle file for it, while the other 3 were current. This is what prevented the project from compiling properly and causing the databinding error.

    The difficult part was that you don't know about this unless you open each build.gradle file and see if there is an error displayed. It did NOT show an error for it on compile.

    Effectively I updated this area to the newer version number to match the other 3 module build.gradle files.

    dependencies {
        ...
        compile 'com.android.support:appcompat-v7:25.2.0'
        compile 'com.android.support:support-v4:25.2.0'
        compile 'com.android.support:recyclerview-v7:25.2.0'
        compile 'com.android.support:design:25.2.0'
        ...
    }
    

提交回复
热议问题