The Connection to the server was unsuccessful(file:///android-asset/www/index.html)
is showing when i run my android application. please let me know how to resolve this issue.
The Connection to the server was unsuccessful(file:///android-asset/www/index.html)
is showing when i run my android application. please let me know how to resolve this issue.
For latest Cordova (4+) this a setting in config.xml
:
e.g.
<preference name="LoadUrlTimeoutValue" value="70000"/>
Increases default timeout to 70 seconds (default is 20), reducing the chance of timing out.
Docs: https://cordova.apache.org/docs/en/latest/config_ref/index.html#preference
When loading a page, the amount of time to wait before throwing a timeout error.
This may asked here many times.. This issue can fix by adding a timeout to the webview call (index.html). In your project_name.java class just add this
super.setIntegerProperty("loadUrlTimeoutValue", 5000);
And in Cordova latest, just use this to timeout
super.loadUrl(Config.getStartUrl(), 5000);
Also go through these so questions
UPDATE :
One more solution, try this
Create a main.html and put your code there, and in your index.html just redirect to main.html
<script>
window.location='./main.html';
</script>
This blog post from Robert Kehoe:
Rename your index.html to "main.html"
Create a new "index.html" and put the following content into it:
<!doctype html>
<html>
<head>
<title>the title</title>
<script>
window.location='./main.html';
</script>
<body>
</body>
</html>
Rebuild your app! No more errors!
Robert also said,
Another good idea is to give your application a “splash screen”, so that the user gets instant feedback that your app is loading/working, before it is fully ready.
The main problem for this issue is take more time to load your page.
yes it's can a hack to solve this issue, make a html page name index.html and your existing index page name to be change as a main.html or any other one give a redirection to this page like this
<script>
window.location='main.html';
</script>
am sure it's work very much
hey i think this error may come load multiple script in starting time so it will take more time.
so you set like this in your java...
super.loadUrl("file:///android_asset/www/index.html");
super.setIntegerProperty("loadUrlTimeoutValue", 600000);
© 2022 - 2024 — McMap. All rights reserved.