当我尝试从Visual Studio Code运行一个简单的React Native应用程序时,我收到以下错误消息。
Scanning folders for symlinks in C:\Projects\MobApp\Project2\sampleapplication\node_modules (286ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
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:59)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
我确保模拟器正在运行,这是我从安装Android Studio时获得的。
运行react-native info后的结果:
Environment:
OS: Windows 7
Node: 9.11.1
Yarn: Not Found
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4720617
Packages: (wanted - installed)
react: 16.3.1 -- 16.3.1
react-native: 0.55.4 -- 0.55.4
我该如何解决这个问题?
答案 0 :(得分:0)
检查 Scanner in = new Scanner(System.in);
System.out.println("Enter a String");
String n = in.nextLine();
String[] parts = n.split(" ");
for(String part : parts) {
if(part.charAt(0)==part.charAt(part.length()-1)) {
System.out.println(part);
}
}
他们应该android/gradlew
而不是755
运行
644
在app根文件夹中,然后运行
chmod 755 android/gradlew
答案 1 :(得分:0)
问题得到了解决。 这是由于代理问题。我们公司有一些设置阻止Android工作室的使用。 在Gradle.properties文件中添加代理后,它开始工作
由于