App Dies On Startup (connection to the server was unsuccessful)
I have an Android application that I\'m writing using PhoneGap BUILD. The app was working fine earli
As you said, there are many duplicate questions on the same topic. Any how explaining your situation.
The problem might be solved by adding a timeout to call your index.html
ie you need to add super.setIntegerProperty("loadUrlTimeoutValue", 70000);
in your activity.java file ( inside src/com/yourProj/--/youractivity.java)
above this line: super.loadUrl("file:///android_asset/www/index.html");
Explanation:
This can be happened due to the following reasons
The core reason: the problem is likely due to the speed of the emulator so the network is too slow complete the communication in a timely fashion.
This can be due to:
Extending loading Timeout Limit will not solve the problem which caused the error, it just will avoid the system to show the message but performance will be affected whatsoever.
Actual reason: You may be linking files or images to remote locations, and those resources are taking too long to load. (this is likely the most common error)
Definitive solution: move all the scripts, images and css needed to some local folders and load them locally ...
Performance will be increased and error will be effectively solved.
fixing this on an ionic app, simply add
<preference name="loadUrlTimeoutValue" value="700000" />
to your config.xml file immediately after this line
<platform name="android">
If you are using visual studio. After changing config.xml sometimes you need this
clean build solution rebuild your app
It is working for me.