Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 381
hata Avatar asked Jul 30 '21 06:07

hata


People also ask

What version of Android Studio does viewbinding work with?

viewBinding { enabled = true } } Please check your Android Studio Version too, It must be 3.6 Canary 11+. NOTE: View binding is available in Android Studio 3.6 Canary 11+.

How to fix unknown_JVMTI_error error in Android Studio?

JVMTI error: UNKNOWN_JVMTI_ERROR To work around this issue in Android Studio 3.5, click Run to re-deploy your app and see your changes. Note: This issue ( #135172147) is fixed in Android Studio 3.6 Canary 6 and higher.

Why doesn’t Android Studio start after installing Android Studio?

Android Studio doesn’t start after installing version 4.2 Studio tries to import previous.vmoptions and sanitize them to work with the garbage collector used by JDK 11. If that process fails, the IDE may not start for certain users who set custom VM options in the.vmoptions file.

How to solve android Data Binding errors?

Three Methods for Solving Android Data Binding Errors 1 View All of the Build Output#N#Android Studio has two different ways to view the build output. The default tree view... 2 Fall Back to the Old Data Binding Compiler Temporarily#N#Starting in version 3.2.1 of Android Studio, the second... 3 Invalidate Caches More ...


1 Answers

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

like image 62
Teralser Avatar answered Oct 14 '22 02:10

Teralser