估計(jì)最近很多新創(chuàng)建flutter項(xiàng)目的小伙伴會(huì)發(fā)現(xiàn),運(yùn)行會(huì)報(bào)錯(cuò)
具體分兩種情況:
iOS報(bào)錯(cuò)
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
[!] Automatically assigning platform `iOS` with version `9.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`.
[!] A license was specified in podspec `integration_test` but the file does not exist - /Users/pedromassango/Desktop/xyz/ios/.symlinks/plugins/integration_test/LICENSE
[!] Unable to read the license file `../LICENSE` for the spec `integration_test (0.0.1)`
[!] Unable to read the license file `../LICENSE` for the spec `integration_test (0.0.1)`
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).
pedromassango@MacBook-Pro-de-MacBook ios %
怎么處理呢否纬?
Automatically assigning platform `iOS` with version `9.0` on target `Runner`
第一個(gè)問題很好解決仍秤,進(jìn)入ios文件夾打開podfile文件,將 platform :ios, '9.0'取消注釋即可彼宠。
后面三個(gè)問題如何解決呢鳄虱?
多是因?yàn)閞uby版本過低導(dǎo)致的,升級(jí)本機(jī)的ruby即可 ,建議升級(jí)到2.7.1
Hello, I have the same problem.
The problem is caused because the function `Dir.new (configuration_engine_dir).each_child` that is inside the file podhelper.rb was introduced only in ruby ??2.5, while the version of it on my machine for example is still in 2.0
There should be some validation on the side of the flutter to avoid problems in this regard
This bug was introduced in this [pull](https://github.com/flutter/flutter/pull/71495)
升級(jí)ruby可以參考這篇文章 升級(jí)ruby
升級(jí)完成以后凭峡,估計(jì)本地的cocoapods也不可用拙已,此時(shí)也需要重新安裝一下(不一定哦,我的就需要重新安裝)摧冀,重新安裝cocoapods可以參考這篇文章 安裝cocoapods倍踪。
安裝完成以后就??啦,運(yùn)行flutter run沒有任何問題了索昂。具體可以參考
flutter官網(wǎng)issue
Android報(bào)錯(cuò):
Exception in thread "main" java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:607)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:61)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 77.0s
Exception: Gradle task assembleDebug failed with exit code 1
是由于下載gradle配置文件建车,而地址卻是國(guó)外的地址,導(dǎo)致下載失敗椒惨,處理方式如下
打開新建的工程項(xiàng)目文件gradle-wrapper.properties(路徑android/gradle/wrapper/gradle-wrapper.properties)
將該文件里面distributionUrl的地址改為本地已經(jīng)下載下來的路徑
distributionUrl=file:///Users/wuai/Downloads/Flutter/gradle/gradle-6.8.1-all.zip
其中g(shù)radle包是從這個(gè)地址下載下來的缤至,如果后面需要更新gradle,可以從這個(gè)地址下載 gradle6.8.1下載