我正在读这本书 “与Arduino,Android和PhoneGap开始NFC近场通信” 。在第29页 “创建PhoneGap项目” 下,我正在尝试使用此命令cordova create ~/Hello com.example.hello Hello
和cordova platform add android
创建一个PhoneGap项目。一切似乎(至少对我而言)一直顺利,直到我尝试运行cordova run
,这会吐出以下几行:
ANDROID_HOME=/home/moki/Work/Tools/android-sdk-linux/
JAVA_HOME=/usr/java/jdk1.8.0_91
No target specified, deploying to device 'CB5A2AKNFT'.
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Connection reset
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:675)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
... 3 more
Error: Error code 1 for command: /home/moki/Work/src/Hello/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/moki/Work/src/Hello/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
我无法弄清问题是什么。我该如何解决这个问题?
我已经安装了Android SDK tools rev 25.1.3
,Android SDK Platform-tools rev 23.1
,Android SDK Build-tools rev 23.0.3
和Android 6.0 (API 23) SDK Platform
。为了能够成功运行我的第一个项目,我还需要做些什么?
我正在尝试在Debian Jessie
操作系统下工作。我还设置了我的Android手机,这是索尼Xperia Z5双重优质,它已经处于开发人员模式,启用了USB调试。
答案 0 :(得分:2)
在您输入“cordova add platform android”后,在CLI中运行“cordova build android”。
玩得开心!