error: package android.view does not exist

Viewed 5147

I am getting this error in view bindings file generated by Android studio. I have added

buildFeatures {
        viewBinding true
    }

to the app build.gradle file.

3 Answers

In your build.gradle(:app) file,

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Try changing the java version. I got the same error when using VERSION_11 but the VERSION_1_8 fixed the issue.

Android Studio don' t update Gradle to version 7. Open project Structure, you can find in File, set in Project: Android Gradle Plugin Version: 7.0.0 and Gradle Version: 7.0.2 Compile now and all will work fine.

Updating the android studio to the latest version fixed the issue for me.

Related