连接服务器失败。(file:///android_asset/www/index.html)

发布于 2024-12-08 02:29:05 字数 552 浏览 0 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七堇年 2024-12-15 02:29:05

我猜它是您使用的端口号。您是否尝试过对服务器使用端口 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.

不再让梦枯萎 2024-12-15 02:29:05

以下代码片段解决了我的问题,

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/home/index.html");
    super.setIntegerProperty("loadUrlTimeoutValue", 10000); 

我已将其添加

super.setIntegerProperty("loadUrlTimeoutValue", 10000); 

到 com.mypackage.xxx.java 文件中
10秒等待时间

The following code snippet solved my problem

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/home/index.html");
    super.setIntegerProperty("loadUrlTimeoutValue", 10000); 

I have added

super.setIntegerProperty("loadUrlTimeoutValue", 10000); 

to the com.mypackage.xxx.java file
for 10 sec waiting time

你的往事 2024-12-15 02:29:05

*我通过参考解决了同样的问题* 这个 链接...

这个错误发生在服务器连接超时的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..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文