报错一) jbr jre 安装包索引不对
解决方案:
// 去Contents 目录
cd /Applications/Android\ Studio.app/Contents
// 创建快捷方式
ln -sf jbr jre
flutter doctor
ln -sf jbr jre
命令
![](https://img.haomeiwen.com/i1194882/3c7e8190df624ffd.png)
解决完毕
![](https://img.haomeiwen.com/i1194882/bd265e4e2ffb2a93.png)
网上很多所谓的创建文件夹拷贝contents 的方式是不行的 , 直接导致Android Studio.app 报文件损坏的错误
报错 2 安卓模拟器的内存不够, 要5个G才可以跑
The Android emulator exited with code 1 during startup Android emulator stderr: ERROR | Not enough space to create userdata partition. Available: 4136.085938 MB at /Users/wanggang/.android/avd/Nexus_7_API_26.avd, need 7372.800000 MB. Address these issues and try again.
清理内存即可 /
报错3) 《Flutter实战·第二版》 书籍demo运行报错 问题
《Flutter实战·第二版》 书籍demo问题
demo来源
对应的源码地址
出现的错误 ①
Because flutter_in_action_2 depends on flukit from path which doesn't exist (could not find package flukit at "../flukit/package_src"), version solving failed.
Running "flutter pub get" in flutter_in_action_2-main...
pub get failed (66; Because flutter_in_action_2 depends on flukit from path
which doesn't exist (could not find package flukit at "../flukit/package_src"),
version solving failed.)
解决方案
## flukit:
## path: ../flukit/package_src
改为
flukit: ^3.0.1
书籍出现的错误②
lib/chapter13/webview.dart:36:30: Error: The method 'showSnackBar' isn't defined for the class 'ScaffoldState'.
- 'ScaffoldState' is from 'package:flutter/src/material/scaffold.dart' ('../../flutter/packages/flutter/lib/src/material/scaffold.dart').
Try correcting the name to the name of an existing method, or defining a method named 'showSnackBar'.
Scaffold.of(context).showSnackBar(
^^^^^^^^^^^^
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
Building macOS application...
Exception: Build process failed
解决办法
错误的api 注释
![](https://img.haomeiwen.com/i1194882/f75f1416cb108642.png)
解决完所有的错误 (完美运行)
![](https://img.haomeiwen.com/i1194882/beefe99ecc61d7e7.png)
报错4) 安卓模拟器安装打怪之路
① 升级flutter
Flutter upgrade升级一直停留在 Running pub upgrade...
解决方案直接下载对应 的SDK
② 缺少安卓stuio
Unable to find bundled Java version 进行链接创建快捷方式 ,我相关的 博客有介绍
This app is using a deprecated version of the Android embedding. To avoid unexpected runtime failure
————————————————
版权声明:本文为CSDN博主「曲黎雪」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_45624072/article/details/127755574
Building a deployable iOS app requires a selected Development Team with a
Provisioning Profile. Please ensure that a Development Team is selected by:
1- Open the Flutter project's Xcode target with
open ios/Runner.xcworkspace
2- Select the 'Runner' project in the navigator then the 'Runner' target
in the project settings
3- Make sure a 'Development Team' is selected under Signing & Capabilities >
Team.
You may need to:
- Log in with your Apple ID in Xcode first
- Ensure you have a valid unique Bundle ID
- Register your device with your Apple Developer Account
- Let Xcode automatically provision a profile for your app
4- Build or run your project again
For more information, please visit:
https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices
Or run on an iOS simulator without code signing
报错5) 使用r刷新界面问题
报错内容:
Another exception was thrown: 'package:flutter/src/widgets/framework.dart':
Failed assertion: line 4313 pos 14: 'owner!._debugCurrentBuildTarget == this':
is not true.
解决方案 :
使用'R'刷新 , 此问题未解决每次需要run 会让人崩溃,无法体验到fluterr 开发的乐趣 .
https://stackoverflow.com/questions/49371221/duplicate-globalkey-detected-in-widget-tree
报错6) provider报错
This is likely caused by an event handler (like a button's onPressed) that called
Provider.of without passing `listen: false`.
To fix, write:
Provider.of<ThemeProvider>(context, listen: false);
此处需要 进行 将watch 改为read
![](https://img.haomeiwen.com/i1194882/d996e92d2f2b92c8.png)
网友评论