不断收到"出现网络错误"测试PhoneGap的应用程序与Eclipse时应用程序、错误、测试、网络

2023-09-06 05:22:23 作者:初心若雪

我只是为了在发射前在我的手机测试获得了PhoneGap的解决方案由分包商。

我将项目导入Eclipse和这一切看起来很好。

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

 文件:// E:/AppDevelopment/Workspace/myproject/assets/www/index.html
 

到目前为止好。然后,我尝试推出一个这样的我的电话(通过USB卡贝尔)。头版打开,但CSS缺失。当我点击任何链接,我得到以下信息:

 出现网络错误(文件:?///android_asset/www/car.html carID = 106
 

有没有人有类似的问题?任何建议,我怎么可以调试有什么不好?

更新

随着Dmyto的建议,我试图改变onReceivedError。但我只得到编码errirs。

 包com.phonegap.mysite;

进口android.os.Bundle;
进口org.apache.cordova *。
进口android.webkit.WebView;
进口android.webkit.WebViewClient;

公共类Mysiteextends DroidGap {
    / **第一次创建活动时调用。 * /
    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        super.loadUrl(文件:///android_asset/www/index.html);

    }

/ **这是它出错** /

    的WebView的WebView =新的WebView(本);

    webview.setWebViewClient(新WebViewClient(){
        @覆盖
        公共无效onReceivedError(web视图来看,INT错误code,字符串描述,字符串failingUrl){
                Log.i(WEB_VIEW_TEST,错误code:+错误code);
                super.onReceivedError(查看,错误code,说明,failingUrl);
        }

}
 
销售技巧 顾客只认你这家,产品火爆卖出的方法

解决方案

没有看到你的 index.html的 code这是很难说,如果你正在引用您正确的CSS文件。此外,该网址:文件:///android_asset/www/car.html=carID=106 似乎并没有有效吗?什么是与 = carID = 106 ?适当的URL应该是?carID = 106 。别急还有更精彩的,有在Android上了一个错误的URL外观和数据无法正确读取。

这是Android上的错误。你应该去星吧:

  HTTPS://$c$c.google.com/p/android/issues/detail ID = 17535
 

在此期间使用 localStorage.setItem() / 的getItem()来传递页面之间的数值。

I've just received the PhoneGap solution from by sub-contractor in order to test it on my phone before launch.

I import the project into Eclipse and it all looks fine.

I can test the app locally on my computer by opening the index.html file:

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

So far so good. Then I try launching this an my phone ( via USB cabel). The front page opens, but the CSS is missing. And when I click any link, I get the following message:

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

Has anyone had similar problems? Any suggestions to how I can debug what is wrong?

UPDATE

Following Dmyto's suggestion, I'm trying to change the onReceivedError. But I only get coding errirs.

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);
        }

}

解决方案

Without seeing your index.html code it is hard to tell if you are referencing your css files properly. Also, that url: file:///android_asset/www/car.html=carID=106 doesn't seem valid? What is with the =carID=106? A proper URL should be ?carID=106. But wait there's more, there is a bug on Android where url paramters are not read properly.

It's a bug on Android. You should go star it:

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

In the meantime use localStorage.setItem()/getItem() to pass values between pages.

 
精彩推荐
图片推荐