2013-08-01 20 views
10

我正在嘗試一個簡單的應用程序,我想在android中的本機包裝內顯示我的移動網站。我正在跟隨文檔,其中我所做的唯一更改是loadUrl,而不是從assets文件夾加載index.html的CordovaWebView,我將它指向一個移動網站,例如https://www.google.com科爾多瓦WebView超時錯誤與Android

webview應用程序出現但沒有收到CordovaWebView TIMEOUT ERROR。以下是從我的代碼片段

public class CordovaWebViewActivity extends Activity implements CordovaInterface{ 

    private CordovaWebView webView; 
    private static final String TAG = "CORDOVA_WEBVIEW_ACTIVITY"; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_cordova_web_view); 

     webView = (CordovaWebView)findViewById(R.id.webview); 
     webView.loadUrl("https://www.google.com"); 


    } 

    @Override 
    public Activity getActivity() { 
    return this; 
    } 
    //... other overrided methods from interface 
} 

,當我運行代碼,我得到我的控制檯以下錯誤DDMS

07-31 20:56:08.737: D/dalvikvm(2016): GC_FOR_ALLOC freed 42K, 6% free 2780K/2928K, paused 23ms, total 25ms 
07-31 20:56:08.746: I/dalvikvm-heap(2016): Grow heap (frag case) to 3.887MB for 1127536-byte allocation 
07-31 20:56:08.777: D/dalvikvm(2016): GC_FOR_ALLOC freed 2K, 4% free 3879K/4032K, paused 36ms, total 36ms 
07-31 20:56:08.836: D/CordovaWebView(2016): CordovaWebView is running on device made by: unknown 
07-31 20:56:08.836: D/JsMessageQueue(2016): Set native->JS mode to 2 
07-31 20:56:08.996: D/gralloc_goldfish(2016): Emulator without GPU emulation detected. 
07-31 20:56:09.376: E/cutils-trace(2016): Error opening trace file: No such file or directory (2) 
07-31 20:56:09.687: D/TilesManager(2016): Starting TG #0, 0x2a26cc40 
07-31 20:56:28.874: E/CordovaWebView(2016): CordovaWebView: TIMEOUT ERROR! 

我有一個config.xml我/ RES/XML文件夾具有以下

<?xml version='1.0' encoding='utf-8'?> 
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets"> 
    <name>Hello Cordova</name> 
    <description> 
     A sample Apache Cordova application that responds to the deviceready event. 
    </description> 
    <author email="[email protected]" href="http://cordova.io"> 
     Apache Cordova Team 
    </author> 
    <content src="index.html" /> 
    <feature name="App"> 
     <param name="android-package" value="org.apache.cordova.App" /> 
    </feature> 
    <access origin="*" /> 
    <preference name="useBrowserHistory" value="true" /> 
    <preference name="exit-on-suspend" value="false" /> 
    <preference name="fullscreen" value="true" /> 
    <preference name="webviewbounce" value="true" /> 
</widget> 

,我也有一個cordova.xml我/ RES/XML文件夾

<?xml version="1.0" encoding="utf-8"?> 

<cordova> 

    <access origin="http://127.0.0.1*"/> <!-- allow local pages --> 
    <access origin="https://www.google.com" /> 


    <log level="DEBUG"/> 
    <preference name="useBrowserHistory" value="false" /> 
</cordova> 

請幫我錯過什麼或做錯了什麼?

+0

您是否找到了解決方案?我面臨同樣的問題。請分享 –

回答

13

你沒有做錯什麼,超時錯誤可能是因爲你的Android手機(或你的模擬器)運行速度太慢。

您可以嘗試增加負載超時下面的指令:

super.setIntegerProperty("loadUrlTimeoutValue", 60000); 

在onCreate方法。或者將其設置在config.xml文件中:

<preference name="loadUrlTimeoutValue" value="60000" /> 
+0

所以,我有同樣的錯誤,我的意思幾乎相同。我有網站加載所有的內容,但一段時間後,我有這個超時錯誤進來。隨着你的修改,它變得更好,但沒有消失。你能告訴我,爲什麼這種幸福,即使在頁面成功加載後? – Karoly