我最近将 Flutter 应用程序升级到了 3.24.1 版本,从那时起,我就无法运行该应用程序。我遇到以下 Gradle 问题:
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply
You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future
release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply
../../../AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.1.1/lib/src/guid.dart:32:9: Error: Type 'UnmodifiableUint8ListView' not found.
final UnmodifiableUint8ListView bytes;
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.1.1/lib/src/guid.dart:32:9: Error: 'UnmodifiableUint8ListView' isn't a type.
final UnmodifiableUint8ListView bytes;
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.1.1/lib/src/guid.dart:52:17: Error: Method not found: 'UnmodifiableUint8ListView'.
return Guid(UnmodifiableUint8ListView(guid));
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.1.1/lib/src/guid.dart:56:31: Error: Method not found: 'UnmodifiableUint8ListView'.
factory Guid.zero() => Guid(UnmodifiableUint8ListView(Uint8List(16)));
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.1.1/lib/src/guid.dart:100:17: Error: Method not found: 'UnmodifiableUint8ListView'.
return Guid(UnmodifiableUint8ListView(Uint8List.fromList(guidAsBytes)));
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/archive-3.4.10/lib/src/bzip2/bzip2.dart:5:7: Error: Method not found: 'UnmodifiableUint8ListView'.
UnmodifiableUint8ListView(Uint8List(0));
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/archive-3.4.10/lib/src/bzip2/bzip2.dart:7:7: Error: Method not found: 'UnmodifiableUint32ListView'.
UnmodifiableUint32ListView(Uint32List(0));
^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/archive-3.4.10/lib/src/bzip2/bzip2.dart:9:7: Error: Method not found: 'UnmodifiableInt32ListView'.
UnmodifiableInt32ListView(Int32List(0));
^^^^^^^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script 'C:\code\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1687
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\code\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 1m 21s
Running Gradle task 'assembleDebug'... 82.2s
Error: Gradle task assembleDebug failed with exit code 1
我尝试清理项目并重新同步 Gradle,但问题仍然存在。我还检查了我的 build.gradle 文件是否有任何过时的依赖项,但没有发现任何异常情况。
扑医生-v
[√] Flutter (Channel stable, 3.24.1, on Microsoft Windows [Version 10.0.19045.4780], locale en-AE)
• Flutter version 3.24.1 on channel stable at C:\code\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5874a72aa4 (8 days ago), 2024-08-20 16:46:00 -0500
• Engine revision c9b9d5780d
• Dart version 3.5.1
• DevTools version 2.37.2
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at C:\Users\jamal\AppData\Local\Android\Sdk
• Platform android-35, build-tools 35.0.0
• ANDROID_HOME = C:\Users\jamal\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.2)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.5.33502.453
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2024.1)
• Android Studio at C:\Program Files\Android\Android Studio
• 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 17.0.11+0--11852314)
[√] VS Code (version 1.92.2)
• VS Code at C:\Users\jamal\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.94.0
[√] Connected device (4 available)
• SM G715FN (mobile) • R58RB0ZASKF • android-arm64 • Android 13 (API 33)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4780]
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.120
• Edge (web) • edge • web-javascript • Microsoft Edge 128.0.2739.42
[√] Network resources
• All expected network resources are available.
• No issues found!
升级后还有其他人遇到过这个问题吗?我应该采取哪些步骤来解决此问题并成功运行我的应用程序?
这是一个已知问题:https://github.com/jonataslaw/get_cli/issues/263
您需要更新 win32 dart 包。
转到您的项目并更新最低 Dart SDK 版本。 对我来说,是3.5.0
pubspec.yaml
environment:
sdk: ">=3.5.0 <4.0.0"
然后清理酒吧缓存:
flutter pub cache clean
并更新过时的 dart 包:
flutter pub outdated
flutter pub upgrade
在日志中您应该看到:
> win32 5.5.4 (was 5.2.0)