大家好,欢迎来到IT知识分享网。
学习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.<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'... 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目录查看目录如下。。。
什么时候有这么多个ndk文件夹了,可能不设置系统默认找ndk-bundle,但是我下载的ndk其实是被放到了ndk文件夹中了,于是在local.properties中添加一行配置,告诉它去这里找ndk
ndk.dir=D:\\soft\\android-sdk-windows\\ndk\\23.0.
23.0.是应该是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 0x --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://yundeesoft.com/48464.html