Reputation: 151
I am really new to Flutter and Dart and while trying to compile my project i got this error:
FAILURE: Build failed with an exception.
* Where:
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'ndkVersion' for extension 'flutter' of type FlutterExtension.
* 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
what can i do to solve this?
I am using Visual Studo Code and just did a fresh install of Flutter from Git, already tried
flutter clean
and
flutter upgrade
but nothing seems to work
Thanks in advance and have a great day.
Upvotes: 15
Views: 24432
Reputation: 1126
In my case I just did flutter upgrade
then the issue was fixed.
Upvotes: 0
Reputation: 151
Go to android>app>build.gradle and change flutter.ndkVersion to the latest stable version. You can check the latest ndk stable version here : https://developer.android.com/ndk/downloads
You go from this : before
to this : after
Upvotes: 15
Reputation: 330
This usually results from running an 'old' project with the latest flutter version.
You need to upgrade your com.android.tools.build:gradle
in project/build.gradle
and distributionUrl
in gradle/gradle-wrapper.properties
to point to a more recent Gradle version.
To update the plugin version, you can check this page here to determine the recent version.
For Gradle version, you can use the Gradle releases page.
Here is a snap of the current status of the releases.
Update Gradle
When you update Android Studio, you may receive a prompt to also update Gradle to the latest available version. You can choose to accept the update or manually specify a version based on your project's build requirements.
The following table lists which version of Gradle is required for each version of the Android Gradle plugin. For the best performance, you should use the latest possible version of both Gradle and the plugin.
Plugin version Minimum required Gradle version 8.0 8.0 7.4 7.5 7.3 7.4 7.2 7.3.3 7.1 7.2 7.0 7.0 4.2.0+ 6.7.1
This should solve your error, unless you are using NDK in your android project.
Upvotes: 3
Reputation: 320
The Solutions above worked for me. Just to re-echo it here.
Go to the android\app\build.gradle
file
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion // line to change
and change ndkVersion
to the latest version. It is probably around line 30.
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion "23.1.7779620"
Upvotes: 3
Reputation: 746
Go to file => android\app\build.gradle
and edit ndkVersion flutter.ndkVersion to ndkVersion "23.1.7779620"
You can find out the latest version from the official website https://developer.android.com/ndk/downloads
Upvotes: 4