文章目录
- 一、报错信息
- 二、问题分析
- 三、解决方案
一、报错信息
参考 【Flutter】Flutter Gallery 官方示例简介 博客 ;
Flutter Galley 开源项目运行时 , 部署到手机时 , 报如下错误 ;
项目地址 : https://github.com/flutter/gallery
This will generate a JSON format file containing all messages that
need to be translated.
Launching lib\main.dart on Pixel 2 in debug mode...
Running Gradle task 'assembleDebug'...
lib/demos/cupertino/cupertino_alert_demo.dart:240:12: Error: Method not found: 'CupertinoModalPopupRoute'.
return CupertinoModalPopupRoute<String>(
^^^^^^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'Y:\001_DevelopTools\010_Flutter\flutter_windows_2.0.2-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'Y:\001_DevelopTools\010_Flutter\flutter_windows_2.0.2-stable\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 19s
Exception: Gradle task assembleDebug failed with exit code 1
二、问题分析
找不到方法 , 怀疑是使用了落后的 Flutter SDK 版本 , 这里更新到最新的测试版本 ;
https://flutter.dev/docs/development/tools/sdk/releases
三、解决方案
下载 2.1.0-12.2.pre 版本的 Flutter SDK ;
flutter_windows_2.1.0-12.2.pre-beta.zip
下载后解压上述 SDK 压缩包 flutter_windows_2.1.0-12.2.pre-beta.zip ;
解压后的 Flutter SDK 路径为 : Y:\001_DevelopTools\010_Flutter\flutter_windows_2.1.0-12.2.pre-beta\flutter ;
在 " File / Settings / Languages & Frameworks / Flutter " 下配置最新版本的 Flutter SDK 路径 ;
Y:\001_DevelopTools\010_Flutter\flutter_windows_2.1.0-12.2.pre-beta\flutter
在 " File / Settings / Languages & Frameworks / Dart " 下配置最新版本的 Dart SDK 路径 ;
Y:\001_DevelopTools\010_Flutter\flutter_windows_2.1.0-12.2.pre-beta\flutter\bin\cache\dart-sdk
最终程序运行成功 :