当我从 sencha touch 开发的 html 文件加载时,会产生如下错误:
E/CordovaWebView(1897): CordovaWebView: TIMEOUT ERROR! CordovaWebViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///android_asset/www/index.html
index.html 是
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Creating a simple XTemplate list in Sencha Touch 2</title>
<link
href="http://cdn.sencha.io/touch/sencha-touch-2.1.0/resources/css/sencha-touch.css"
rel="stylesheet" />
<script
src="http://cdn.sencha.io/touch/sencha-touch-2.1.0/sencha-touch-all-debug.js"
type="text/javascript"></script>
<link href="app/styles.css" rel="stylesheet" type="text/css" />
<script src="app.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
应用程序.js
/*global Ext:false */
Ext.application({
launch: function () {
Ext.create('Ext.Container', {
fullscreen: true,
styleHtmlContent: true,
data: [{
fname: 'Stratton',
lname: 'Sclavos',
role: 'Executive Chairman'
}, {
fname: 'Michael',
lname: 'Mullany',
role: 'CEO'
}, {
fname: 'Ted',
lname: 'Driscoll',
role: 'Vice President Worldwide Sales'
}, {
fname: 'Abraham',
lname: 'Elias',
role: 'Chief Technical Officer'
}, {
fname: 'Jeff',
lname: 'Hartley',
role: 'Vice President of Services and Training'
}, {
fname: 'Adam',
lname: 'Mishcon',
role: 'Vice President of Operations'
}, {
fname: 'Judy',
lname: 'Lin',
role: 'Vice President of Engineering'
}], // data
tpl: '<tpl for="."><div><strong>{lname}</strong>, {fname} <em class="muted">({role})</em></div></tpl>'
}); // create()
} // launch
}); // application()
主要活动,java
package com.example.senchahelloandroid;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}