Flutter 应用程序在最新更新后无法运行
Posted
技术标签:
【中文标题】Flutter 应用程序在最新更新后无法运行【英文标题】:Flutter App Failed To Run after latest Update 【发布时间】:2020-10-24 14:18:52 【问题描述】:环境详情 Windows + VS 代码 Flutter 1.17.5 • 通道稳定 • https://github.com/flutter/flutter.git 框架 • 修订版 8af6b2f038(3 天前) • 2020-06-30 12:53:55 -0700 引擎 • 修订版 ee76268252 工具• Dart 2.8.4
来自调试控制台的错误
E:\apps\flutterCode\android\app\src\main\java\com\example\testApp\MainActivity.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
E:\apps\flutterCode\android\app\src\main\java\com\example\TestApp\MainActivity.java:10: error: cannot find symbol
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine)
^
symbol: class NonNull
location: class MainActivity
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 10s
Exception: Gradle task assembleDebug failed with exit code 1
【问题讨论】:
我找到了一个解决方法,新建一个flutter项目,复制android文件夹然后替换旧项目中的android文件夹。 【参考方案1】:尝试将Android/build.gradle
中的最低 SDK 版本从 16 更改为 21。
如果仍然无法正常工作,请尝试如下更改build type
函数。
buildTypes
release
minifyEnabled true
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
【讨论】:
以上是关于Flutter 应用程序在最新更新后无法运行的主要内容,如果未能解决你的问题,请参考以下文章
Flutter App 无法在 IoS 模拟器上运行,运行器内有循环,并且 domain=NSPOSIXErrorDomain,code=63
Flutter:在 MacOs Big Sur (VirtualBox) 上设置 Android Studio 后无法运行程序