【问题标题】:Cannot run flutter application on first run, gradle error首次运行时无法运行颤振应用程序,gradle 错误
【发布时间】:2021-06-04 03:34:02
【问题描述】:

我创建了一个新的颤振应用程序,但我无法让它第一次运行。它卡在运行 Gradle 任务 assembleDebug。这是我收到的错误消息

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)

我跑过颤振医生,这是结果

[√] 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!

【问题讨论】:

    标签: android flutter gradle


    【解决方案1】:

    对于 Android studio 4.1.1+ (gradle-plugin: 4.1.1 or above) 使用 ndkVersion

    local.properties 中没有 ndk.dir。如果有,删除它

    build.gradle(模块)

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

    或者在您的 Android Studio 中,转到 File -> Project Structure -> SDK Location -> Under "Android NDK Location",点击“下载”Android NDK

    等待下载并重新构建项目。干杯。

    【讨论】:

    • 运行颤振医生并在这里发帖
    • 我找不到这个位置文件 -> 项目结构 -> SDK 位置 -> 在“Android NDK 位置”下
    • 我用颤振的医生结果编辑了这个问题
    猜你喜欢
    • 2020-03-15
    • 2021-11-09
    • 2021-04-19
    • 1970-01-01
    • 1970-01-01
    • 2018-11-19
    • 2020-02-20
    • 2020-04-27
    • 2022-01-09
    相关资源
    最近更新 更多