- 问题:新建项目卡住
解决:换源,并配置到环境变量 - 问题:Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
解决:忽略不影响 - 问题:Build failed due to use of deprecated Android v1 embedding.
解决:使用了flutter v2的sdk编译项目,而你的项目是旧的v1时候开发的,
Upgrading pre 1.12 Android projects · flutter/flutter Wiki (github.com) - 问题:pub get failed exit code: 69
解决:查看flutter doctor,修复问题 - 问题: Windows Version (Unable to confirm if installed Windows version is 10 or greater)
解决:切换flutter渠道
[1] 在cmd输入flutter channel 查看自己的flutter channel版本
[2] 输入flutter channel master,将flutter版本切换为master
[3]输入flutter upgrade 确保flutter更新到了最新版本
[4]输入 flutter doctor 再次检查是否解决 - 问题:flutter assemble --output directory is required for assemble.
解决: - 问题:flutter Failed to download
https://storage.flutter-io.cn/flutter_infra_release/flutter/d492b8b3a56729397743957de82be7cc1c6f4c6d/windows-x64-debug/w
indows-x64-flutter.zip. Ensure you have network connectivity and then try again.
Exception: 503
解决:检查是否有代理,或者检查网络
- 问题:flutter run andorid 报错Target file "android" not found
解决:flutter -d b7ec9ed0 run - 问题:Exception in thread "main" java.net.ConnectException: Connection timed out: connect
解决:连接超时,是因为distributionUrl的网址被墙了,所以连接的时候总是连接不上。添加阿里镜像可以解决问题。
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
- 问题:flutter create 指令
解决: flutter create --org com.chatgpt.client chatgpt_client - 问题:flutter run 指令
解决:flutter -d b7ec9ed0 run - 问题:No file or variants found for asset: messages.json.
解决:检查assets下message.json是否存在,
检查pubspec.yaml 下assets: - assets/是否正确 - 问题:flutter doctor 卡住
解决:等待,一般不会特别久 - 问题:java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/plugin/KotlinBasePlugin
解决:kotlin插件版本错误,最新版的1.8.20移除该类
kotlin 插件与agp的对应关系,可以查询
kotlin-gradle-plugin远程仓库
或者官方说明
Configure a Gradle project | Kotlin Documentation (kotlinlang.org) - 问题:The constructor being called isn't a const constructor.
解决:dart新版本的语法检查导致,Diagnostic messages | Dart,
增加构造函数const Home({super.key});或者使用StatefulWidget, - 问题:Navigator operation requested with a context that does not include a Navigator
解决:检查代码,main中需要StatelessWidget,home为StatefulWidget - 问题:可点击范围太小
解决:behavior: HitTestBehavior.opaque,或者用背景色填充 - 问题:Unsupported operation: Platform._operatingSystem
解决:web平台优先判断 - 问题:cannot modify unmodifiable map
解决:未定位,修改代码解决 - 问题:Trying to load an image from another domain
解决:flutter run -d chrome --web-renderer html - 问题:flutter Web 项目网络请求报 XMLHttpRequest error
解决:
找到flutter sdk目录
然后找到flutter\packages\flutter_tools\lib\src\web\chrome.dart文件并打开
找到'--disable-extensions'位置,然后添加'--disable-web-security'
另外还需要到flutter\bin\cache目录下,删除flutter_tools.stamp和flutter_tools.snapshot的文件,否则改动不生效