最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - The connection to the server was unsuccessful.(file:android_assetwwwindex.html) - Stack Overflow

programmeradmin4浏览0评论

I am developing a android app using phonegap, it calls a website (: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?

I am developing a android app using phonegap, it calls a website (http://siteaddress.: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?

Share Improve this question asked Oct 3, 2011 at 10:42 ArifArif 1962 gold badges3 silver badges9 bronze badges 1
  • if necessary, when should these two lines should run? – omid.n Commented May 15, 2014 at 7:52
Add a ment  | 

3 Answers 3

Reset to default 3

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.

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 .mypackage.xxx.java file for 10 sec waiting time

*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..

发布评论

评论列表(0)

  1. 暂无评论