Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why this error in my PhoneGap app for Android ?

When run in the emulator (using Phonegap 1.1.0, Mac 10.6, Eclipse 3.7.1) I get this error:

12-01 11:49:12.936: D/chromium(1062): Unknown chromium error: -6
...
12-01 11:49:13.476: I/System.out(1062): onReceivedError: Error code=-1 Description=A network error occurred. URL=file://android_asset/www/index.html

and on a device I get this error:

12-01 11:50:37.644: I/System.out(5319): onReceivedError: Error code=-14 Description= 
The  requested file was not found. /android_asset/www/index.html (No such file or directory)       URL=file://android_asset/www/index.html

My app is just a bare bones demo type app, so far the only code in it is this javascript in the index.html file

function onBodyLoad()
{          
    document.addEventListener("deviceready",onDeviceReady,false);
}

function onDeviceReady()
{    
    document.addEventListener("resume", onResume, false);
    onResume();     
}

function onResume(){
    openBrowser('http://www.mysite.com/wap');  
    //navigator.app.exitApp();
}

function openBrowser(url){
      // document.location= url;
}

I was looking at other posts about similar errors and they all seem to suggest setting the java like so:

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setStringProperty("loadingDialog", "Title,Message"); 
    this.setIntegerProperty("loadUrlTimeoutValue", 70000);

   // setContentView(R.layout.main);
    super.loadUrl("file://android_asset/www/index.html");
}

or something like that, but it has been no help so far. Why am I getting these errors and what can I do about them? Thanks

like image 452
lost baby Avatar asked Dec 01 '11 17:12

lost baby


1 Answers

I needed three slashes after this: super.loadUrl("file:

Instead of:

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

Use:

super.loadUrl("file:///android_asset/www/index.html");
like image 59
lost baby Avatar answered Sep 22 '22 16:09

lost baby