Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Could not find method viewBinding() for arguments

I am trying to implement ViewBinding on Android Studio as described in the documentation.

But I get following error:

ERROR: Could not find method viewBinding() for arguments [build_86jkemkg0wj9ybuijdbbuahly$_run_closure1$_closure5@2714f9c5] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

I have the latest version of Android Studio for Linux.

Why I am getting an error?

like image 873
Muhammed Ozdogan Avatar asked Sep 15 '19 20:09

Muhammed Ozdogan


2 Answers

8/3/2020 update
After update to AS 3.6.1 you should update your android gradle version to 3.6.1 > classpath 'com.android.tools.build:gradle:3.6.0'


Orignal solution
Android Studio 3.6 and above, From the Left menu, select Project > Gradle Scripts > gradle-wrapper.properties then modify the distributionUrl and set it to https\://services.gradle.org/distributions/gradle-5.6.4-all.zip after that sync your project with Sync Project with Gradle Files, after it's finished go back to your build.gradle (Project) and update the dependencie of gradle classpath to classpath 'com.android.tools.build:gradle:3.6.0', almost done.
Now it's time to enable it, in your build.gradle(:app) set it

viewBinding {
    enabled = true
}

12/16/2020 update

With classpath 'com.android.tools.build:gradle:4.1.1' viewBinding is deprecated, you have to use:

buildFeatures {
    viewBinding = true
}
like image 182
Amjad Alwareh Avatar answered Oct 12 '22 18:10

Amjad Alwareh


Help->About says Android Studio 3.5

View binding is a part of Android Studio 3.6. Right now, that is in a preview ("canary") release version.

Is it a feature that will be implemented at next version?

Correct. If you wish, you can install the preview version of Android Studio 3.6 alongside your Android Studio 3.5, to experiment with the feature. Or, you can wait a few months for Android Studio 3.6 to ship a release version, then use view binding at that point.

like image 18
CommonsWare Avatar answered Oct 12 '22 20:10

CommonsWare