Search code examples
javaandroidandroid-studioandroid-viewbinding

ViewBinding with Java11, AndroidStudio always shows error (but runs without any problem)


I notice that with Java8 there is no problem with viewBinding in AndroidStudio (Arctic Fox).

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
    viewBinding true
}

However, once I set compileOptions to JavaVersion.VERSION_11, AndroidStudio always falsely shows viewBiding(s) errors though it can compile and run with no problem.

I tested this with a fresh new project in AndroidStudio ArcticFox. It suggests to import the class. After imported, it says Package not found:

screenshot 1

screenshot 2

Is this AndroidStudio's bug, or are there any misconfiguration about Java compiler setting in my AndroidStudio?

All I did something particular was JavaVersion.VERSION_11.


Solution

  • As google's support answered: This issue has been fixed and landed in BB canary 8. It is specific to Java 11.