Reputation: 67
I have created Android + Cordova project for the purpose of creating and testing cordova plugin but when app opens it gives me the following error.Application Error Connection to server was unsuccessful (file:///android_asset/www/main.html)
MainActivity.java
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 6000);
super.loadUrl("file:///android_asset/www/main.html");
}catch(Exception e){
e.printStackTrace();
}
} }
I have added Cordova jar in the lib folder and cordova.js and main.html file in assets/www folder. This error already present on StackOverflow but that doesn't solve my problem.
Upvotes: 1
Views: 5281
Reputation: 461
In Ionic App with Android 4.x mobile version the same error appears. The workaround is adding time to the timeout to launch the App in config.xml.
<preference name="loadUrlTimeoutValue" value="700000" />
Maybe in Android native version you can try something similar to increase that timeout.
It seems that the error is because the timeout finish before the app loads. I hope this help you.
Look this thread: Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
Upvotes: 1