简体   繁体   中英

Cannot run flutter application on first run, gradle error

I have created a new flutter app and I cannot get it to run for the first time. It gets stuck at running Gradle task assembleDebug. This is the error message I get

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> NDK at C:\Users\Hp\AppData\Local\Android\sdk\ndk-bundle did not have a source.properties file

* 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 3m 10s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

I have ran flutter doctor and this are the results

[√] Flutter (Channel stable, 2.0.0, on Microsoft Windows [Version 10.0.19041.804], locale en-US)
    • Flutter version 2.0.0 at C:\dev\flutter
    • Framework revision 60bd88df91 (2 days ago), 2021-03-03 09:13:17 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Hp\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.54.1)
    • VS Code at C:\Users\Hp\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.20.0

[√] Connected device (3 available)
    • Redmi 6 (mobile) • a28707477d26 • android-arm    • Android 9 (API 28)
    • Chrome (web)     • chrome       • web-javascript • Google Chrome 88.0.4324.190
    • Edge (web)       • edge         • web-javascript • Microsoft Edge 88.0.705.81

• No issues found!

For Android studio 4.1.1+ (gradle-plugin: 4.1.1 or above) use ndkVersion

No ndk.dir at local.properties. If there is, remove it

build.gradle (module)

android {
  defaultConfig {
     // ...
     ndkVersion = "21.1.6352462"
  }
}

Or In your Android Studio, Go to File -> Project Structure -> SDK Location -> Under "Android NDK Location" , click on "Download" Android NDK

Wait for download and re-build the project. Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM