Javascript Phonegap在android emulator上不工作(找不到index.html)
我正在使用phonegap创建一个显示html5网页的本机android应用程序,问题是在模拟器上,该应用程序会产生一个应用程序错误,说明:Javascript Phonegap在android emulator上不工作(找不到index.html),javascript,android,html,cordova,Javascript,Android,Html,Cordova,我正在使用phonegap创建一个显示html5网页的本机android应用程序,问题是在模拟器上,该应用程序会产生一个应用程序错误,说明: "the connection to the server was unsuccesfull(file://android_assets/www/index.html)" 同一个应用程序在我的HTC One X上启动得很好,所以我认为这不是我代码的问题 这是我的android代码 public class MainScreen extends Droid
"the connection to the server was unsuccesfull(file://android_assets/www/index.html)"
同一个应用程序在我的HTC One X上启动得很好,所以我认为这不是我代码的问题
这是我的android代码
public class MainScreen extends DroidGap
{
private Caller caller;
private static final String Wrapper = "Wrapper";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
caller = new Caller(this,appView);
appView.addJavascriptInterface(caller, Wrapper);
super.loadUrl(Config.getStartUrl());
//super.loadUrl("file:///assets/www/index2.html");
// Set by <content src="index.html" /> in config.xml
public class Caller {
private Wrapper mwrapper;
private String serverDomain;
private String serverFromIp;
private String serverToIp;
private String username;
private String password;
private WebView mWebView;
private DroidGap mGap;
public Caller(DroidGap gap, WebView webview){
mGap = gap;
mWebView = webview;
mwrapper = new Wrapper();
//TODO: figure out a way to handle callback
}
@JavascriptInterface
public int register(){
}
@JavascriptInterface
public void send(String message){
}
}
通过遵循这个让它工作起来似乎不正确。index.html应该是合法的。还有其他选择吗?
05-31 09:27:09.690: E/CordovaWebView(1642): CordovaWebView: TIMEOUT ERROR!
05-31 09:27:09.690: D/Cordova(1642): CordovaWebViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///android_asset/www/index.html
05-31 09:27:09.700: D/DroidGap(1642): onMessage(onReceivedError,{"errorCode":-6,"url":"file:\/\/\/android_asset\/www\/index.html","description":"The connection to the server was unsuccessful."})