Flutter 踩坑🕳️ 记,持续更新~

更新日期:2019年12月17日

  • 用这个包 agora_rtc_engine之后,IOS模拟器跑不起来了😢,报错如下:
➜ pika git:(zxs-dev) ✗ flutter run

Launching lib/main.dart on iPhone XR in debug mode...

Running pod install... 0.9s

CocoaPods' output:

↳

 Preparing

 Analyzing dependencies

 Inspecting targets to integrate

 Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

 Finding Podfile changes

 - Flutter

 - agora_rtc_engine

 - city_pickers

 - connectivity

 - fluttertoast

 - image_picker

 - permission_handler

 - screen

 - shared_preferences

 Fetching external sources

 -> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`

 -> Fetching podspec for `agora_rtc_engine` from `.symlinks/plugins/agora_rtc_engine/ios`

 -> Fetching podspec for `city_pickers` from `.symlinks/plugins/city_pickers/ios`

 -> Fetching podspec for `connectivity` from `.symlinks/plugins/connectivity/ios`

 -> Fetching podspec for `fluttertoast` from `.symlinks/plugins/fluttertoast/ios`

 -> Fetching podspec for `image_picker` from `.symlinks/plugins/image_picker/ios`

 -> Fetching podspec for `permission_handler` from `.symlinks/plugins/permission_handler/ios`

 -> Fetching podspec for `screen` from `.symlinks/plugins/screen/ios`

 -> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`

 Resolving dependencies of `Podfile`

 [!] CocoaPods could not find compatible versions for pod "AgoraRtcEngine_iOS":

 In snapshot (Podfile.lock):

 AgoraRtcEngine_iOS (= [2.4.0.1](2.4.0.1))

 In Podfile:

 agora_rtc_engine (from `.symlinks/plugins/agora_rtc_engine/ios`) was resolved to 2.4.0, which depends on

 AgoraRtcEngine_iOS (= [2.4.0.1](2.4.0.1))

 None of your spec sources contain a spec satisfying the dependency: `AgoraRtcEngine_iOS (= [2.4.0.1](2.4.0.1))`.

 You have either:

 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.

 * mistyped the name or version.

 * not added the source repo that hosts the Podspec to your Podfile.

 Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in

 `raise_error_unless_state'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in

 unwind_for_conflict'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in

 `unwind_for_conflict'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:257:in

 `process_topmost_state'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/resolver.rb:123:in `resolve'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:781:in `block

 in resolve_dependencies'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:779:in

 `resolve_dependencies'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:88:in

 `analyze'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:243:in `analyze'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:154:in `block in

 resolve_dependencies'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:153:in

 `resolve_dependencies'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:116:in `install!'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/bin/pod:22:in `load'

 /usr/local/Cellar/cocoapods/1.5.3_1/libexec/bin/pod:22:in `<main>'

Error output from CocoaPods:

↳

 [!] The version of CocoaPods used to generate the lockfile (1.6.1) is higher than the version of the current

 executable (1.5.3). Incompatibility issues may arise.

 [!] Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified.

 Please specify a platform for this target in your Podfile. See

 `[https://guides.cocoapods.org/syntax/podfile.html#platform](https://guides.cocoapods.org/syntax/podfile.html#platform)`.

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.

To update the CocoaPods specs, run:

 pod repo update

Error running pod install

Error launching application on iPhone XR.

😄 解决方法:升级一下pod就行了
1、命令行输入 pod repo update
2、进入项目的IOS目录,运行命令 pod install


  • 如果不希望 Column 撑满容器: mainAxisSize: MainAxisSize.min

  • 用命令创建 Flutter 项目(据说这样创建的项目比较完整,这样说会不会被打😱)
    flutter create --org=包名 --project-name=项目文件的名字 文件路径,例如:
// 会在当前目录,创建一个 demo 文件夹,flutter项目名称为 demo,包名 cn.demotech.demo
flutter create --org=cn.demotech --project-name=demo ./demo

其余配置信息可以通过 flutter create -h命令查看,自行配置

运行 flutter packages get,显示 ⣯Enter passphrase for key '/Users/:root/.ssh/i

报错信息.png

解决方式: 将SSH私钥添加到SSH -agent并将密码存储在密钥链中。 ssh-add -K ~/.ssh/id_rsa


  • flutter 版本更新问题
    运行命令 flutter upgrade 升级后提示需要 brew upgrade ios-deploy,运行后报错
Error: The following directories are not writable by your user:
/usr/local/share/man/man5
/usr/local/share/man/man7

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7

And make sure that your user has write permission.
  chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7

解决办法:

sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share

  • 上传图片和视频到 OSS 界面卡顿
    在项目开发中,发现图片和视频上传的时候,界面就是会卡死一下。后来发现,是在封装的 请求api 文件中打印了请求信息,把请求信息注释掉就解决了 🎉🎉🎉

  • 减小 Android 的release 包
    在 android => app => src => build.gradle 中的 defaultConfig 添加配置:
 defaultConfig {
        ......
         ndk {
             abiFilters 'armeabi-v7a'
         }
    }

这个表示这个 app 支持 armeabi-v7a 架构的手机,也支持 arm64,不支持armeabi(例如小米3) 。不写这个打 release 包的时候就会包括各种不必要的结构,等于so包要多好多个,假如一个架构的so包有10M 两个就是20M 。。。


  • 上传视频到 OSS 不成功
    上传视频生成的路径格式,可能不符合所要的格式,需做截取

  • APP上传到 appStore 不成功
    别人的电脑都可以但是只有的不行,后来经过检查应该是我的VPN 或者DNS配置有问题导致部分网站访或者App Store无法访问,那么这个时候就要恢复一下mac de 的网络出厂设置了
    步骤一、点击Finder ->go->computer(中文的小伙伴,自行翻译)
    步骤二、选择Macintosh hd。
    步骤三、选择library,中文系统里是资源库。
    步骤四、找到preferences文件夹。
    步骤五、打开systemconfiguration这个文件夹。

    步骤六、把下图中选中的文件都删除,就剩下一个comapple.boot.plist。如下图
    image

    步骤七、重启电脑。
    最后,本方法来源于网络,亲测有效。
    顺带一提,Xcode11 之后上传包到App Store 可以用 transporter(App Store可以下载) 非常便捷。嗖嗖嗖~
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,298评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,701评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 107,078评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,687评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,018评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,410评论 1 211
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,729评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,412评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,124评论 1 239
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,379评论 2 242
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,903评论 1 257
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,268评论 2 251
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,894评论 3 233
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,014评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,770评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,435评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,312评论 2 260

推荐阅读更多精彩内容