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可以下载) 非常便捷。嗖嗖嗖~
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容