Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Databinding seems to be broken after adding Room

After adding

compile "android.arch.persistence.room:runtime:1.0.0-rc1"

all of my data binding classes are broken. Any clue?

like image 822
Zahid Rasheed Avatar asked Oct 20 '17 13:10

Zahid Rasheed


2 Answers

Turns out, javac will print a maximum of 100 compilation errors, and when dealing with preprocessors you often want the last error message, not the first. Put this in your top-level build.gradle file and become happy:

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xmaxerrs" << "4000"
            options.compilerArgs << "-Xmaxwarns" << "4000"
        }
    }
}

Thanks to: https://movieos.org/2017/android-room-data-binding-compile-time-errors/

like image 68
Zahid Rasheed Avatar answered Oct 24 '22 11:10

Zahid Rasheed


As others have stated, the issue is not with your Data Binding classes/setup, but rather an error somewhere in your Room annotations. In my case, it was an error with the DAO class. If you're on an old version of the gradle plugin, You see all of the Data Binding compiler errors before getting the room compiler errors, which is the error that points to the actual issue in your Room code.

This was fixed in the 3.4 Android Gradle plugin, so you can now update to that (this requires Android Studio 3.4 or higher). It'll prompt you to update the Android gradle plugin the first time you open the project:

enter image description here

More information (including the code to print out all of the compiler errors) here.

like image 1
Lyla Avatar answered Oct 24 '22 09:10

Lyla