这在我之前的任何 flutter 项目中都从未发生过,但是当我尝试在模拟器中运行我的应用程序时,应用程序会弹出,然后崩溃,没有任何错误消息,并继续构建应用程序,没有发生任何事情。
我做了一些测试,发现当我在 android 目录的 build.gradle 文件中添加“buildscript{}”时,它开始发生:
buildscript { ext.kotlin_version = '1.9.0' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.1.2' // START: FlutterFire Configuration classpath 'com.google.gms:google-services:4.4.2' // Required for Firebase // END: FlutterFire Configuration classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir }
有时我会收到错误消息,提示 kotlin 版本与二进制版本不匹配。
我拥有最新版本的 flutter,并且已经尝试过“flutter pub升级”、“flutter clean”等等。
这是我的扑动医生:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows
[Version 10.0.22631.4317], locale pt-PT)
[√] Windows Version (Installed version of Windows is version 10
or higher)
[!] Android toolchain - develop for Android devices (Android SDK
version 32.1.0-rc1)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for
more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK
licenses.
See https://flutter.dev/to/windows-android-setup for more
details.
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio
Community 2022 17.8.3)
X Visual Studio is missing necessary components. Please
re-run the Visual Studio installer for the "Desktop
development with C++" workload, and include these
components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available,
install the latest
C++ CMake tools for Windows
Windows 10 SDK
[!] Android Studio (not installed)
[√] IntelliJ IDEA Ultimate Edition (version 2023.2)
[√] VS Code (version 1.94.2)
[√] Connected device (4 available)
[√] Network resources
flutter doctor --android-licenses
上运行 cmd
并接受许可证。