Search code examples
androidflutterkotlindartflutter-packages

Could not find method buildFeatures() for arguments [] on object of type com.android.build.gradle.LibraryExtension


I added the package 'qr_code_scanner: ^0.5.1' into my pubspec.yaml.

After restarting my app, the following error appeared:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner- 
0.5.1\android\build.gradle' line: 39

* What went wrong:
A problem occurred evaluating project ':qr_code_scanner'.
> Could not find method buildFeatures() for arguments 
[build_983ew3001pu1n91tvzyoag4vc$_run_closure2$_closure7@3a00d2ee] on object of type 
com.android.build.gradle.LibraryExtension.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get 
more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Exception: Gradle task assembleDebug failed with exit code 1

My flutter doctor:

enter image description here

I really don't know what caused the error.

Thank you for all reply!


Solution

    • stop project

    • delete the folder (C:\Flutter\flutter.pub-cache\hosted\pub.dartlang.org\qr_code_scanner- 0.5.1

    • change to version "qr_code_scanner: ^0.4.0",

    • run flutter pub get

    • run project again

    • for my case it worked