连接服务器失败。(file:///android_asset/www/index.html)
我正在使用phonegap开发一个android应用程序,它调用一个网站(http://siteaddress.com:8081)来获取json编码数据。这在模拟器上工作正常,然后我使用phonegap build构建了android包.apk文件,但是当我在我的Android手机上安装这个包并启动应用程序时,它强制关闭应用程序,显示错误“与服务器的连接是不成功。(file:///android_asset/www/index.html)”。
我已经使用phonegap build构建了应用程序,将index.html传递给它并尝试了.zip文件包,但仍然收到此错误。我尝试搜索此错误,并按照某些网站的建议在我的应用程序中包含以下代码,但仍然出现错误。
super.setBooleanProperty("loadInWebView", true);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
这与我尝试从我的应用程序调用的网站有关吗?我尝试在移动浏览器中打开该网站,但它没有打开,但该网站在桌面浏览器上运行良好。我做错了什么吗?
I am developing a android app using phonegap, it calls a website (http://siteaddress.com:8081) to get json encoded data. This is working fine on the emulator, then I built the android package .apk file using phonegap build but when i installed this package on my android phone and started the app, it force closes the application showing the error "The connection to the server was unsuccessful.(file:///android_asset/www/index.html)".
I have built the app using phonegap build, passed it the index.html as well as tried the .zip file package but still getting this error. I tried searching for this error and also included the below code in my app as suggested on some sites but still it is giving error.
super.setBooleanProperty("loadInWebView", true);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
Has this got something to do with the website that i am trying to call from my app? I tried opening that site in the mobile browser but it didn't opened but the website works fine on a desktop browser. Is there something wrong that i am doing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜它是您使用的端口号。您是否尝试过对服务器使用端口 80 而不是 8081?您的设备上的端口可能未打开。
I'm guessing its the port number your using. Have you tried using port 80 for your server rather than 8081? Its possible that port isn't open on your device.
以下代码片段解决了我的问题,
我已将其添加
到 com.mypackage.xxx.java 文件中
10秒等待时间
The following code snippet solved my problem
I have added
to the com.mypackage.xxx.java file
for 10 sec waiting time
*我通过参考解决了同样的问题* 这个 链接...
这个错误发生在服务器连接超时的bcoz,所以,已经提到在上面的帖子中你可以给10秒的延迟在那段时间放了一些闪屏..
*I had Same problem solved by referring * this link...
This error occurs bcoz of Server connection timeout so, Has mentioned in above post u can give 10 sec delay in that time put some splash screen..