android - 使用 Eclipse 测试 PhoneGap 应用程序时不断收到 "A network error occurred"

标签 android eclipse cordova

我刚刚收到分包商提供的 PhoneGap 解决方案,以便在发布前在我的手机上进行测试。

我将项目导入到 Eclipse 中,一切看起来都很好。

我可以通过打开index.html 文件在我的计算机上本地测试该应用程序:

file://E:/AppDevelopment/Workspace/myproject/assets/www/index.html

到目前为止一切顺利。然后我尝试在我的手机上启动它(通过 USB 电缆)。首页打开,但 CSS 丢失。当我单击任何链接时,我会收到以下消息:

"A network error occurred. (file:///android_asset/www/car.html?carID=106"

有人遇到过类似的问题吗?对于如何调试错误有什么建议吗?

更新

按照 Dmyto 的建议,我正在尝试更改 onReceivedError。但我只遇到编码错误。

package com.phonegap.mysite;

import android.os.Bundle;
import org.apache.cordova.*;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Mysiteextends 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");

    }

/** This is where it goes wrong **/

    WebView webview = new WebView(this);

    webview.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Log.i("WEB_VIEW_TEST", "error code:" + errorCode);
                super.onReceivedError(view, errorCode, description, failingUrl);
        }

}

最佳答案

如果没有看到您的 index.html 代码,就很难判断您是否正确引用了 css 文件。另外,该网址:file:///android_asset/www/car.html=carID=106 似乎无效? =carID=106 是怎么回事?正确的 URL 应该是 ?carID=106。但等等,还有更多,Android 上有一个错误,无法正确读取 url 参数。

这是 Android 上的一个错误。你应该给它加注星标:

https://code.google.com/p/android/issues/detail?id=17535

同时使用localStorage.setItem()/getItem()在页面之间传递值。

关于android - 使用 Eclipse 测试 PhoneGap 应用程序时不断收到 "A network error occurred",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10433978/

相关文章:

android - 带 POS 的 NFC - Android

java - Nexus 7 4.2 上的 Android Java 日历日期 WEEK_OF_YEAR 问题

java - 通用动画叠加 View 的枢轴不起作用

android - Android 设备上的照片方向

java - 使用 readDouble 从套接字输入读取 Double + EOL

eclipse - Git 和 egit 关于文件模式 10064 的冲突,尽管文件模式设置为 false

android - 为什么 Android API 级别 15 中的 "Buttons in button bars should be borderless"?

java - eclipse中的快捷方式与tab相反?

android - PhoneGap/Cordova Android 在 onDeviceReady 后获取屏幕尺寸

ios - 在 IOS 上调试 Ionic 应用程序?