Flutter 踩坑??? 記,持續(xù)更新~

更新日期:2019年12月17日

  • 用這個(gè)包 agora_rtc_engine之后,IOS模擬器跑不起來(lái)了??,報(bào)錯(cuò)如下:
? 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.

?? 解決方法:升級(jí)一下pod就行了
1、命令行輸入 pod repo update
2、進(jìn)入項(xiàng)目的IOS目錄,運(yùn)行命令 pod install


  • 如果不希望 Column 撐滿容器: mainAxisSize: MainAxisSize.min

  • 用命令創(chuàng)建 Flutter 項(xiàng)目(據(jù)說(shuō)這樣創(chuàng)建的項(xiàng)目比較完整,這樣說(shuō)會(huì)不會(huì)被打??)
    flutter create --org=包名 --project-name=項(xiàng)目文件的名字 文件路徑,例如:
// 會(huì)在當(dāng)前目錄,創(chuàng)建一個(gè) demo 文件夾,flutter項(xiàng)目名稱為 demo,包名 cn.demotech.demo
flutter create --org=cn.demotech --project-name=demo ./demo

其余配置信息可以通過(guò) flutter create -h命令查看,自行配置

運(yùn)行 flutter packages get,顯示 ?Enter passphrase for key '/Users/:root/.ssh/i

報(bào)錯(cuò)信息.png

解決方式: 將SSH私鑰添加到SSH -agent并將密碼存儲(chǔ)在密鑰鏈中。 ssh-add -K ~/.ssh/id_rsa


  • flutter 版本更新問(wèn)題
    運(yùn)行命令 flutter upgrade 升級(jí)后提示需要 brew upgrade ios-deploy,運(yùn)行后報(bào)錯(cuò)
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 界面卡頓
    在項(xiàng)目開(kāi)發(fā)中,發(fā)現(xiàn)圖片和視頻上傳的時(shí)候,界面就是會(huì)卡死一下。后來(lái)發(fā)現(xiàn),是在封裝的 請(qǐng)求api 文件中打印了請(qǐng)求信息,把請(qǐng)求信息注釋掉就解決了 ??????

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

這個(gè)表示這個(gè) app 支持 armeabi-v7a 架構(gòu)的手機(jī),也支持 arm64,不支持armeabi(例如小米3) 。不寫這個(gè)打 release 包的時(shí)候就會(huì)包括各種不必要的結(jié)構(gòu),等于so包要多好多個(gè),假如一個(gè)架構(gòu)的so包有10M 兩個(gè)就是20M 。。。


  • 上傳視頻到 OSS 不成功
    上傳視頻生成的路徑格式,可能不符合所要的格式,需做截取

  • APP上傳到 appStore 不成功
    別人的電腦都可以但是只有的不行,后來(lái)經(jīng)過(guò)檢查應(yīng)該是我的VPN 或者DNS配置有問(wèn)題導(dǎo)致部分網(wǎng)站訪或者App Store無(wú)法訪問(wèn),那么這個(gè)時(shí)候就要恢復(fù)一下mac de 的網(wǎng)絡(luò)出廠設(shè)置了
    步驟一、點(diǎn)擊Finder ->go->computer(中文的小伙伴,自行翻譯)
    步驟二、選擇Macintosh hd。
    步驟三、選擇library,中文系統(tǒng)里是資源庫(kù)。
    步驟四、找到preferences文件夾。
    步驟五、打開(kāi)systemconfiguration這個(gè)文件夾。

    步驟六、把下圖中選中的文件都刪除,就剩下一個(gè)comapple.boot.plist。如下圖
    image

    步驟七、重啟電腦。
    最后,本方法來(lái)源于網(wǎng)絡(luò),親測(cè)有效。
    順帶一提,Xcode11 之后上傳包到App Store 可以用 transporter(App Store可以下載) 非常便捷。嗖嗖嗖~
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容