扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Dart语言中文网 http://dart.goodev.org/
创新互联建站专业提供成都主机托管四川主机托管成都服务器托管四川服务器托管,支持按月付款!我们的承诺:贵族品质、平民价格,机房位于中国电信/网通/移动机房,服务器托管服务有保障!Flutter官网 https://flutter.dev/
Flutter中文网 https://flutterchina.club/
一、windows环境搭建
配置镜像(加快FlutterSDK下载)
官方写的这个export是用在linux上的
export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
window上要将export换成set,但是去环境变量界面查看竟然没有
cmd 输入set,会查看所有的环境变量,发现有设置的环境变量。
下载FlutterSDK
下载FlutterSDK,在path里配置“flutter\bin”的环境变量。
执行flutter doctor,下载FlutterSDK相关的依赖。
二、创建Flutter项目
创建项目
这里的flutter sdk path就是flutter文件夹位置
*****和创建Android APP项目对比可发现,没有了minSdk、targetSdk这些个选项。(意思)
运行项目
首次运行,可能会有以下错误:
Launching lib\main.dart on SM N9009 in debug mode... Initializing gradle... Finished with error: ProcessException: Process "F:\Work\Flutter\flutter_app\android\gradlew.bat" exited abnormally: Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. Exception in thread "main" javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1551) at sun.security.ssl.AppInputStream.available(AppInputStream.java:60) at java.io.BufferedInputStream.available(BufferedInputStream.java:410) at sun.net.www.MeteredStream.available(MeteredStream.java:170) at sun.net.www.http.KeepAliveStream.close(KeepAliveStream.java:85) at java.io.FilterInputStream.close(FilterInputStream.java:181) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(HttpURLConnection.java:3448) at org.gradle.wrapper.Download.downloadInternal(Download.java:77) 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) Caused by: javax.net.ssl.SSLException: java.net.SocketException: Connection reset at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916) at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1880) at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1825) at sun.security.ssl.AppInputStream.read(AppInputStream.java:116) at java.io.BufferedInputStream.read1(BufferedInputStream.java:284) at java.io.BufferedInputStream.read(BufferedInputStream.java:345) at sun.net.www.MeteredStream.read(MeteredStream.java:134) at java.io.FilterInputStream.read(FilterInputStream.java:133) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3375) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3368) at org.gradle.wrapper.Download.downloadInternal(Download.java:62) ... 7 more Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593) at sun.security.ssl.InputRecord.read(InputRecord.java:532) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940) at sun.security.ssl.AppInputStream.read(AppInputStream.java:105) ... 14 more Command: F:\Work\Flutter\flutter_app\android\gradlew.bat -v
这个是在下载gradle,网络不好的原因。如果网络好了,run会自动下载gradle,run成功之后,控制台会显示:
Launching lib\main.dart on SM N9009 in debug mode... Initializing gradle... Resolving dependencies... [{"event":"app.progress","params":{"appId":"d62136c6-30c8-4426-8e6e-e1ec5bdf918e","id":"2","progressId":null,"message":"Running Gradle task 'assembleDebug'..."}}]Running Gradle task 'assembleDebug'... Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... [{"event":"app.progress","params":{"appId":"d62136c6-30c8-4426-8e6e-e1ec5bdf918e","id":"4","progressId":null,"message":"Syncing files to device SM N9009..."}}]Syncing files to device SM N9009...
赶紧体验了一把“热重载”特性,实在是非常爽!!!
另外,通过控制台日志可以发现:
Launching lib\main.dart on SM N9009 in debug mode... Initializing gradle... Resolving dependencies... Running Gradle task 'assembleDebug'... Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... Syncing files to device SM N9009...
项目第一次run的时候,也会生成apk文件。
打开项目出现一直提示加载的问题
Android Studio使用flutter upgrade等时提示waiting for another flutter command to release the startup lock
解决办法:
先打开任务管理器,结束掉所有dart.exe。然后打开你的flutter安装文件夹,找到\bin\cache中的lockfile文件删除。之后重启Android Studio。
依赖package
****更新yaml文件之后,点击Packages get,即可将包下载下来。
然后在dart里import
**** yaml文件,点击Get dependencies,会报下面的错误,不用管就行。
Working dir: F:\Work\Flutter\startup_namer G:\Android\flutter_windows_v1.7.8+hotfix.4-stable\flutter\bin\cache\dart-sdk\bin\pub.bat upgrade Resolving dependencies... Because startup_namer depends on flutter_test any from sdk which doesn't exist (the Flutter SDK is not available), version solving failed. Flutter users should run `flutter pub get` instead of `pub get`. Process finished with exit code 69
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流