0

当我从 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");

    }

}
4

1 回答 1

0

好的,你可以做一些事情来解决这个问题:

  • 检查您是否在 AndroidManifest 文件中设置了 INTERNET_CONNECTION 的权限。
  • 您可以尝试从 Internet 下载链接文件(Sencha-touch.csssencha-touch-all-debug.js)并将它们本地化。
  • 您可以添加这一行super.setIntegerProperty("loadUrlTimeoutValue", 7000); 在 super.onCreate(savedInstanceState) 下;在您的 MainActivity.java 文件中
于 2013-06-03T10:52:19.003 回答