0

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.

dny
  • 57
  • 2
  • 10
  • Not sure what tutorial or what are you following to do what you are doing, but it's extremely out of date. Droidgap has not been used for years. If you want to create and test plugins, just create a regular Cordova project and add the plugin using a local path and with --link option, that will allow you to edit the source code while the changes are linked to the classes on the local folder you used to install. – jcesarmobile Dec 26 '17 at 15:37
  • Possible duplicate of [Application Error - The connection to the server was unsuccessful. (file:///android\_asset/www/index.html)](https://stackoverflow.com/questions/12319809/application-error-the-connection-to-the-server-was-unsuccessful-file-andr) – Ravimallya Jul 23 '18 at 07:41

1 Answers1

0

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)

monikaja
  • 381
  • 2
  • 9