2

I get this error. What should I do?

The path is valid and I've checked it. And I've made a clean and rebuilt the app again, and so forth. I really don't know what to do next!

In my activity class I have the following code:

import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;

public class TestPhoneGapActivity extends DroidGap {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // setContentView(R.layout.main);
        String url = "file:///assets/www/index.html"; 
        super.loadUrl(url); 
    }
}

application_error

marko
  • 10,684
  • 17
  • 71
  • 92

6 Answers6

1

i had this problem and i fixed it like this..

super.loadUrl("file:///android_asset/www/index.html"); 

to

super.loadUrl("file:///android_asset/www/index.htm");
Karthick pop
  • 616
  • 3
  • 16
0

You might need to use IceCreamCordovaWebViewClient

@Override
    public void init() {
    super.init(webView, new IceCreamCordovaWebViewClient(this, webView), new CordovaChromeClient(this, webView));
}
Clayton Rabenda
  • 5,229
  • 2
  • 19
  • 16
0

Check your asset/www/ folder. Check the index.html file is there.

Sajith
  • 2,842
  • 9
  • 37
  • 49
0

I found a really good solution to this online.

What you basically need to do is to move the contents of index.html to another file, say app.html.

Then have the following code in your original index.html:

<!doctype html>
<html>
<head>
   <title>your app name</title>
</head>
<body>
   <script>
       window.location='./app.html';
   </script>
</body>
</html>

The connection to the server won't timeout anymore and the app should load successfully.

Now I didn't come up with this great idea. All credit goes to Robert Kehoe:

https://www.robertkehoe.com/2013/01/fix-for-phonegap-connection-to-server-was-unsuccessful/

Doing this helped me solve a similar problem with my own Android phonegap application...

Daniel
  • 1,352
  • 1
  • 14
  • 16
0

check your www folder, I think there is no index.hmtl in there

chrisSy
  • 11
-1

Raj Patel answer works! should use super.loadUrl("file:///android_asset/www/index.html"); although the folder in called assets in eclipse

  • I'm getting a similar error, except that I already have "super.loadUrl("file:///android_asset/www/index.html");" set :/ – danjah Jan 27 '13 at 10:09