Android 在运行KitKat的Nexus7上将HTML5/js加载到WebView失败,但在运行姜饼的手机上可以

Android 在运行KitKat的Nexus7上将HTML5/js加载到WebView失败,但在运行姜饼的手机上可以,android,android-webview,Android,Android Webview,我需要将HTML5/Javascript游戏加载到WebView中 由于这在运行姜饼的旧手机上有效,但在运行KitKat的Nexus7上失败,我猜可能与Android 4.4中新的基于Chromium的WebView有关? 这款游戏在Nexus7上的Chrome浏览器中运行良好,但在我的应用程序的WebView中运行不好 如果您能给我一些建议,帮助我找出问题的根源,我将不胜感激 在Nexus7上运行时的LogCat是: 05-29 13:49:46.421 2526-2526/au.com

我需要将HTML5/Javascript游戏加载到WebView中

由于这在运行姜饼的旧手机上有效,但在运行KitKat的Nexus7上失败,我猜可能与Android 4.4中新的基于Chromium的WebView有关? 这款游戏在Nexus7上的Chrome浏览器中运行良好,但在我的应用程序的WebView中运行不好

如果您能给我一些建议,帮助我找出问题的根源,我将不胜感激

在Nexus7上运行时的LogCat是:

05-29 13:49:46.421    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GameActivity﹕ Logged into Facebook
05-29 13:49:46.421    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GameActivity﹕ mNewCheckin = false
05-29 13:49:47.371    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GameActivity﹕ checkInToPlay()
05-29 13:49:47.371    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GameActivity﹕ Showing Game
05-29 13:49:47.371    2526-2526/au.com.xxxxxxx.xxxxxxxxxx V/WebViewChromium﹕ Binding Chromium to the background looper Looper (main, tid 1) {4204a888}
05-29 13:49:47.371    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
05-29 13:49:47.381    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/BrowserProcessMain﹕ Initializing chromium process, renderers=0
05-29 13:49:47.381    2526-2563/au.com.xxxxxxx.xxxxxxxxxx W/chromium﹕ [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
05-29 13:49:47.421    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ Loading URL into WebView
05-29 13:49:47.491    2526-2526/au.com.xxxxxxx.xxxxxxxxxx W/AwContents﹕ nativeOnDraw failed; clearing to background color.
05-29 13:49:47.501    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ Page Started Loading...
05-29 13:49:47.501    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageStarted:WebView ID: 2131296360
05-29 13:49:47.501    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageStarted:URL: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html
05-29 13:49:47.621    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:CONSOLE(9)] "Viewport argument key "minimal-ui" not recognized and ignored.", source: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html (9)
05-29 13:49:48.951    2526-2540/au.com.xxxxxxx.xxxxxxxxxx W/ContextImpl﹕ Implicit intents with startService are not safe: Intent { act=com.google.android.gms.analytics.service.START (has extras) } android.content.ContextWrapper.bindService:517 com.google.analytics.tracking.android.AnalyticsGmsCoreClient.connect:82 com.google.analytics.tracking.android.GAServiceProxy.connectToService:330
05-29 13:49:48.951    2526-2540/au.com.xxxxxxx.xxxxxxxxxx W/GAV3﹕ Thread[GAThread,5,main]: Service unavailable (code=1), will retry.
05-29 13:49:48.961    2526-2540/au.com.xxxxxxx.xxxxxxxxxx I/GAV3﹕ Thread[GAThread,5,main]: No campaign data found.
05-29 13:49:49.381    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ ...Page Finished Loading
05-29 13:49:49.381    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:WebView ID: 2131296360
05-29 13:49:49.381    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:URL: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html
05-29 13:49:49.411    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
05-29 13:49:49.431    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
05-29 13:49:49.681    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:CONSOLE(153)] "Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.", source: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/c2runtime.js (153)
05-29 13:49:49.781    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ ...Page Finished Loading
05-29 13:49:49.781    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:WebView ID: 2131296360
05-29 13:49:49.781    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:URL: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html
05-29 13:49:49.931    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ ...Page Finished Loading
05-29 13:49:49.931    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:WebView ID: 2131296360
05-29 13:49:49.931    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:URL: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html
05-29 13:49:49.971    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ ...Page Finished Loading
05-29 13:49:49.971    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:WebView ID: 2131296360
05-29 13:49:49.971    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:URL: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html
05-29 13:49:49.991    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
05-29 13:49:50.081    2526-2601/au.com.xxxxxxx.xxxxxxxxxx E/MediaResourceGetter﹕ Invalid url: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
05-29 13:49:50.081    2526-2564/au.com.xxxxxxx.xxxxxxxxxx E/MediaResourceGetter﹕ Invalid url: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
05-29 13:49:50.081    2526-2600/au.com.xxxxxxx.xxxxxxxxxx E/MediaResourceGetter﹕ Invalid url: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
05-29 13:49:50.131    2526-2564/au.com.xxxxxxx.xxxxxxxxxx E/MediaResourceGetter﹕ Invalid url: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
05-29 13:49:50.151    2526-2601/au.com.xxxxxxx.xxxxxxxxxx E/MediaResourceGetter﹕ Invalid url: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
05-29 13:49:50.231    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ ...Page Finished Loading
05-29 13:49:50.231    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:WebView ID: 2131296360
05-29 13:49:50.231    2526-2526/au.com.xxxxxxx.xxxxxxxxxx D/GamePlayFragment﹕ onPageFinished:URL: http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/index.html
05-29 13:49:51.011    2526-2526/au.com.xxxxxxx.xxxxxxxxxx I/chromium﹕ [INFO:CONSOLE(1)] "Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings.  It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.", source: https://www.facebook.com/connect/ping?client_id=.........
05-29 13:49:53.961    2526-2592/au.com.xxxxxxx.xxxxxxxxxx W/ContextImpl﹕ Implicit intents with startService are not safe: Intent { act=com.google.android.gms.analytics.service.START (has extras) } android.content.ContextWrapper.bindService:517 com.google.analytics.tracking.android.AnalyticsGmsCoreClient.connect:82 com.google.analytics.tracking.android.GAServiceProxy.connectToService:330
05-29 13:49:53.971    2526-2592/au.com.xxxxxxx.xxxxxxxxxx W/GAV3﹕ Thread[Service Reconnect,5,main]: Service unavailable (code=1), using local store.
05-29 13:49:54.001    2526-2592/au.com.xxxxxxx.xxxxxxxxxx D/dalvikvm﹕ GC_FOR_ALLOC freed 1133K, 11% free 10204K/11372K, paused 26ms, total 27ms
下面是我目前如何实现WebView的

    // webview
    final WebView webView = (WebView)view.findViewById(R.id.game_webview);
    webView.setWebChromeClient(new WebChromeClient());
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }
    });
    webView.loadUrl("http://www.xxxxxxx.xxx.xx/xxxxx/xxx/index.html");

“在谷歌搜索了很多次之后,这似乎是由于在html中使用了相对引用造成的”——据我所知,
loadUrl()
,相对引用从来都不是问题。相对引用可能是
loadData()
的问题,但不是
loadUrl()
@commonware的问题。谢谢我想我理解错了,一直在寻找错误的方向。有没有什么建议,在运行KitKat的Nexus7手机上,而不是在运行姜饼的旧手机上,什么更可能导致这些错误。我会立即查看您的日志,查看“MediaResourceGetter”周围的行﹕ “无效url”行,查看您是否可以确定它抱怨的url,因为这可能有助于缩小范围。同样,如果该错误行是一个更大的堆栈跟踪的一部分,您可能会考虑编辑您的问题并提供完整的堆栈跟踪,这可能会给我们更多的线索。我已经按照建议修改了问题。我将研究一些
chromium
消息,例如
异步像素传输不受支持
未捕获的InvalidStateError:试图使用不可用或不再可用的对象。“,资料来源:http://www.xxxxxxx.com.au/xxxxxx/xxx/xxxxxxxxx/xxxxx/xxx/c2runtime.js