凯发体育官方-ag凯发国际 > 好文阅读

搬砖的一天开始了

学习flutter ,新建了一个项目,想要将项目运行到夜神安卓模拟器当中,开发工具使用的是vscode,vscode已经正常连接模拟器,运行报如下异常。。。。

ps d:\workspace\flutter-space\startup_namer> flutter run
launching lib\main.dart on oppo r11 plus in debug mode...
running gradle task 'assembledebug'...
exception in thread "main" java.net.connectexception: connection timed out: connect
        at java.net.dualstackplainsocketimpl.connect0(native method)
        at java.net.dualstackplainsocketimpl.socketconnect(dualstackplainsocketimpl.java:79)
        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.plainsocketimpl.connect(plainsocketimpl.java:172)
        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.(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'...                             22.2s
exception: gradle task assembledebug failed with exit code 1

通过以上异常信息可以发现应该是在gradle构建项目时报错,有安卓开发经验应该知道gradle的下载经常是非常慢的,还经常下载不成功。打开gradle-wrapper.properties 内容如下

#fri jun 23 08:50:38 cest 2017
distributionbase=gradle_user_home
distributionpath=wrapper/dists
zipstorebase=gradle_user_home
zipstorepath=wrapper/dists
distributionurl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

推测项目应该是无法找到gradle_user_home,而且系统也没有设置gradle_user_home的环境变量,于是配置环境变量,我的gradle是放在d盘

环境变量配置

配置完成之后,重新flutter run...

重跑之后发现gradle的报错已经没有了,但是又报如下ndk错误...

execution failed for task ':app:stripdebugdebugsymbols'.
> ndk at d:\soft\android-sdk-windows\ndk-bundle did not have a source.properties file

心中浮现了三只草泥马

项目找不到ndk于是打开安卓内的local.properties

flutter.sdk=d:\\soft\\flutter\\flutter
sdk.dir=d:\\soft\\android-sdk-windows
flutter.buildmode=debug
flutter.versionname=1.0.0
flutter.versioncode=1

flutter和sdk配置都没有错,回到sdk目录查看目录如下。。。

安卓sdk目录

什么时候有这么多个ndk文件夹了,可能不设置系统默认找ndk-bundle,但是我下载的ndk其实是被放到了ndk文件夹中了,于是在local.properties中添加一行配置,告诉它去这里找ndk

ndk.dir=d:\\soft\\android-sdk-windows\\ndk\\23.0.7599858

23.0.7599858是应该是ndk的版本。。。报错还有可能是ndk没有下载哦!!!!

重新运行又报错了,但是感觉离成功越来越近了

ps d:\workspace\flutter-space\startup_namer> flutter run
launching lib\main.dart on oppo r11 plus in debug mode...
running gradle task 'assembledebug'...                              9.6s
√  built build\app\outputs\flutter-apk\app-debug.apk.
installing build\app\outputs\flutter-apk\app.apk...                 4.9s
processexception: process exited abnormally:
error: protocol fault (couldn't read status): connection reset by peer
  command: d:\soft\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 shell am start -a android.intent.action.run -f 0x20000000 --ez enable-background-compilation true --ez
  enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true com.example.startup_namer/com.example.startup_namer.mainactivity

草泥马的漠视

看一下好像是adb的错,可能跟项目没有关系,重跑一次就可以了。

于是我又开始愉快地搬砖了。。。

继续搬

本文来自投稿,不代表本网站立场,发布者:实习编辑,如若转载,请注明出处:https://www.fur.net.cn/yuedu/492237.html

关注微信
网站地图