PhoneGap - When deployed on device none of the styles or javascript files are loaded?
I am just writing a small part of a phonegap version of another app I am working on.
However I have hit a bizarre problem. When I run the html files locally via firefox all works fine and seems great. However when I deploy to the device th开发者_运维百科e html file loads ok, however there are no styles, and none of the javascript seems to be loaded.
My directory structure is like: (original *A*ssets was a typo)
{project}/assets/www/
| - scripts/
| - styles/
| - index.html
My links from the index to css and js look like:
<link type="text/css" rel="stylesheet" href="styles/jquery.mobile-1.0a4.1.min.css" />
My apk file contains all these files (I have checked within Winrar), I thought maybe it was a case thing, but everything is lower case and referenced as so. I am deploying to Android 1.6 but have tried 2.1 and 2.2 as well, no luck there either.
Anyone had anything similar happen?
Does your Java source load Assets/index.html? The loadUrl typically maps file:///android_asset/... to the assets directory. Note the lowercase assets.
There should be a file src/{packageName}/{activityName}.java that looks like :
package {packageName};
import com.phonegap.*;
import android.os.Bundle;
public class activity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}`
}
精彩评论