Enable viewBinding feature failed (Android Studio 3.6)

Thanks for you support !

I've solved it by using Android Gradle Plugin 3.6.0-alpha12


As given in Official Website

Put it like:

android {
    ...
    viewBinding {
        enabled = true
    }
}

Please check your Android Studio Version too, It must be 3.6 Canary 11+.

Also check Gradle Plugin - Android Gradle Plugin 3.6.0-alpha12

NOTE: View binding is available in Android Studio 3.6 Canary 11+.


Some things have changed a little if you are using Android Gradle plugin >= 4.0.0-alpha05.

viewBinding.enabled = true is now deprecated

You should use the Android buildFeatures block instead:

android {
    buildFeatures {
        // Determines whether to support View Binding.
        // Note that the viewBinding.enabled property is now deprecated.
        viewBinding = true
    }
}

If you want the feature enabled by default in all of your modules you can turn on it in gradle.properties:

android.defaults.buildfeatures.viewBinding=true

Docs: https://developer.android.com/studio/preview/features/#4.0