找不到类的android.webkit.WebResourceResponse'在Android 2.2上运行HelloCordova时 [英] Could not find class 'android.webkit.WebResourceResponse' when running HelloCordova on Android 2.2

查看:1128
本文介绍了找不到类的android.webkit.WebResourceResponse'在Android 2.2上运行HelloCordova时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按照这个教程: <一href="http://docs.phonegap.com/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android">http://docs.phonegap.com/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android

和收到以下错误:

05-08 15:35:59.845: E/dalvikvm(307): Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.getWhitelistResponse

下面一个人解释了错误:<一href="https://issues.apache.org/jira/browse/CB-3041">https://issues.apache.org/jira/browse/CB-3041

Here a guy explains the error: https://issues.apache.org/jira/browse/CB-3041

This is a known issue. Because Android 2.3 does not have android.webkit.WebResourceResponse, this code is considered dead by Android 2.3's Dalvik. This means your whitelisting doesn't work properly like it does on Android 4.x, as per CB-2099. I'm going to keep this open, but lower the priority, since we know what causes it and it's an easy "First Bug" for someone if they really want to fix this.

他告诉修复很容易,但并没有解释如何解决它-.- 辉煌!

He tells the fix is easy, but does not explain how to fix it -.- Brilliant!

显然,一个固定不与Android 2.2的模拟器,因为它的工作原理与Android 4.2运行它。

Obviously one fix is not to run it with an Android 2.2 emulator because it works with Android 4.2.

但我怎么得到它在Android 2.2的工作?

But how do I get it working in Android 2.2?

我想建立一个应用程序,是由API级别8个,最多不兼容。

I want to build an application that is compatible from API Level 8 and up.

推荐答案

这是因为Android 2.2的没有更新的WebKit与WebResource响应。

This is because Android 2.2 does not have the updated webkit with WebResource Response.

尝试下载从科尔多瓦2.2罐子这里,并把它在你的/ libs文件夹在你的项目的基础。如果没有,创建一个。您可能还需要添加<一个href="https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java"相对=nofollow> IceCreamCordovaWebViewClient.java 您的来源(如果你选择下载科尔多瓦源$ C ​​$ C并将其添加为一个依赖,你可以将它添加到源)

Try downloading the cordova 2.2 jar from here and putting it in you /libs folder at the base of your project. If there is none, create one. You might also have to add IceCreamCordovaWebViewClient.java to your sources (or if you choose to download the source code of cordova and add it as a dependency, you can add it to that source)

或者你可以尝试使用普通的 WebViewClient / ChromeClient ,做自己的工作,为的 MH 概述了这个帖子,复制。

Or you can try using a regular WebViewClient/ChromeClient and doing the work yourself, as MH outlines in this post, copied below.

如果你想要做类似的针对Android 2.X的东西,你可能要   请尝试使用前面提到的 shouldOverrideUrlLoading(web视图   看来,字符串URL),以避免加载页面,手动取水的时候,   更换参考用自己的CSS文件,最后调用    loadData(字符串数据,字符串MIMETYPE,字符串编码)(或    loadDataWithBaseURL(字符串的baseUrl,字符串数据,字符串MIMETYPE,   字符串编码,字符串historyUrl))上的WebView,传入   操纵HTML内容为一个字符串。

If you want to do something similar for Android 2.x, you might want to try using the earlier mentioned shouldOverrideUrlLoading(WebView view, String url) to avoid loading the page, fetch it manually, replace the reference to the css file with your own, and finally call loadData(String data, String mimeType, String encoding) (or loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl)) on the WebView, passing in the manipulated html content as a string.

编辑:

此外,你还可以尝试添加WebResourceResponse和依赖关系到你的src文件夹。尝试从<一个下载它们href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/webkit/WebResourceResponse.java"相对=nofollow>这里

Also, you can also try adding WebResourceResponse and dependencies to your src folder. Try downloading them from here

这篇关于找不到类的android.webkit.WebResourceResponse'在Android 2.2上运行HelloCordova时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆