King Goeks King Goeks - 1 month ago 23
Android Question

PhoneGap 1.8.1 - super.loadUrl("file:///android_asset/www/index.html") issue

I'd just download and use latest version of phonegap : v.1.8.1

as usual, I replace the

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


When I test my "hello world" application, it will always force close. The app can't run properly. But if i change back the line into
setContentView(R.layout.main)
, the app will run properly and there is no problem (for the application). The real problem is, the application not load the index.html because there is no
super.loadUrl("file:///android_asset/www/index.html");
line.

here is my code :

package com.urfinder.android;

import android.os.Bundle;

import org.apache.cordova.DroidGap;

public class URFinderActivity extends DroidGap {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

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

}
}`


Anyone can give me some advise about this?
Thank you :)

Answer

1) In your html file, have u put this line in <head>?

<script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>

2) Add this line on top of your activity

import org.apache.cordova.*;

3) Have you copy cordova-1.8.1.jar from your Cordova download earlier into folder /libs

4) Have you configure project Build Path?

Right click on the /libs folder and go to Build Paths/ > Configure Build Path.... Then, in the Libraries tab, add cordova-1.8.1.jar to the project

5) Have you copy cordova.xml and plugins.xml file from your Cordova download earlier into folder /res/xml

This is your check list. Hope it help.