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
I was facing the same issue. I noticed that in my index i had both the "on device ready" and the "document.ready" function, so removing one of them fixed my problem :)
Remove the external scripts in your index.html
Change this:
<script src="http://code.highcharts.com/highcharts-more.js"></script>
to
<script src="project_folder/highcharts-more.js"></script>
Another reason this error might occur is: there is no index.html
in .../YourApp/www/
!
I just followed the ionic guide, and one of the steps is:
$ rm www/index.html
On iOS this is no problem as during the build the compiler takes some default HTML instead. However, when building for android, NO example index.html
is used. Took me sometime to find out ("WHY does it work on iOS, but not on android...?)
Easy solution: create a index.html, save it under .../YourApp/www
, rebuild ...et voila!
Check you index.html
file. If you use external resources, that not available when you run application then you can get this error.
In my case I forgot to delete link on debugger script (weinre).
<script src="http://192.168.0.102:8080/target/target-script-min.js#anonymous"></script>
So application worked on emulator because http://192.168.0.102:8080/
was on my localhost and available for emulator.
But when I setup application on mobile phone I had same error, because 192.168.0.102 was not available from mobile network.
For my case, the problem was due to losing of the internet connection in my WiFi.
In your config.xml file add this line:
<preference name="loadUrlTimeoutValue" value="700000" />