ERROR: Could not find method viewBinding() for arguments

隐身守侯 提交于 2020-02-29 20:09:22

问题


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?


回答1:


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.




回答2:


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
}


来源:https://stackoverflow.com/questions/57947991/error-could-not-find-method-viewbinding-for-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!