2012-11-03 70 views
3

我的環境:
的Eclipse SDK 4.2.1
科爾多瓦2.2.0(PhoneGap的)
目標平臺:安卓4.0.3(API等級15)的Android - PhoneGap的 - 出現網絡錯誤

我已經嘗試通過許多論壇(包括這一個)搜索,似乎無法找到解決這個問題。

首先,assets/www目錄中的頁面之間的鏈接工作正常。然而,在一個頁面中,我有:

<a href="http://www.google.com">Google</a> 

我也曾嘗試rel="external"爲一體的屬性,但結果是一樣的。

根據路線I在Android白名單已specfied google.com通過添加:

<access origin="http://google.com" subdomains="true" /> 

至RES/XML/config.xml文件。

從點擊上述鏈路上的結果是:

Application Error
A network error occurred. (http://www.google.com/)

和應用程序崩潰。

我在爲API Level 15設置的AVD管理器(模擬器)以及功能設備(HTC One X與Android 4.0.3)上都得到了結果。這兩者都可以上網。

任何建議,將不勝感激。

+0

我似乎無法重現此錯誤。 –

回答

0

D/Cordova ( 560): onPageFinished(file:///android_asset/www/index.html) D/chromium( 560): Unknown chromium error: -400 D/DroidGap( 560): onMessage(onPageStarted,http://www.google.com/) D/Cordova ( 560): CordovaWebViewClient.onReceivedError: Error code=-1 Descripti on=A network error occurred. URL=http://www.google.com/ D/DroidGap( 560): onMessage(onReceivedError,{"errorCode":-1,"url":"http://www .google.com/","description":"A network error occurred."}) D/DroidGap( 560): onMessage(onPageStarted,http://www.google.com/) D/Cordova ( 560): onPageFinished(http://www.google.com/) D/DroidGap( 560): onMessage(onNativeReady,null) D/DroidGap( 560): onMessage(onPageFinished,http://www.google.com/) D/SoftKeyboardDetect( 560): Ignore this event D/Cordova ( 560): onPageFinished(http://www.google.com/) D/DroidGap( 560): onMessage(onNativeReady,null) D/DroidGap( 560): onMessage(onPageFinished,http://www.google.com/)

我唯一一次見過一個-400錯誤是指在互聯網 權限丟失:

<uses-permission android:name="android.permission.INTERNET"/> 
0

你需要一個固定的白名單中?

我通常去罰款:

<access origin="*" /> 

的問題可能是,谷歌正在轉發到另一個端口(HTTPS/443),這樣子站點規範也無濟於事。

或者你可以嘗試沒有指定的協議:

<access origin="google.com" subdomains="true" /> 

,或者嘗試使用通配符as described here

<access origin="*google.com*" /> 
相關問題