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

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

问题描述

我试图遵循本教程:
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):找不到类'android.webkit.WebResourceResponse',从方法org.apache.cordova.CordovaWebViewClient.getWhitelistResponse 

这里有一个人解释错误: https://issues.apache。 org / jira / browse / CB-3041

 这是一个已知的问题。由于Android 2.3没有android.webkit.WebResourceResponse,这个代码被Android 2.3的Dalvik视为死了。这意味着您的白名单无法正常工作,就像在Android 4.x上一样,按照CB-2099。我会保持这个开放,但是降低优先级,因为我们知道是什么原因,而且对于某人来说,这是一个容易的第一个Bug,如果他们真的想解决这个问题。 

他告诉修复很容易,但不解释如何修复它-.-
Brilliant!



显然,一个修复程序不是用Android 2.2模拟器来运行,因为它适用于Android 4.2。



我想要构建一个兼容于API 8级以上的应用程序。

解决方案

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



尝试从此处下载cordova 2.2 jar并将其放在/ libs文件夹中在你的项目的基础。如果没有,创建一个。您可能还需要添加 IceCreamCordovaWebViewClient.java (或者如果您选择下载cordova的源代码并将其添加为依赖关系,则可以将其添加到该源)



或者您可以尝试使用常规的 WebViewClient / ChromeClient 并自己做这些工作,如 MH 在下面复制的此帖中的大纲。


如果你想为Android 2.x做类似的事情,你可能想要
尝试使用前面提到的 shouldOverrideUrlLoading(WebView
视图,String url)
以避免加载页面,手动抓取,
用您自己的文件替换对css文件的引用,而fi nData调用
loadData(String data,String mimeType,String encoding)(或
loadDataWithBaseURL(String baseUrl,String data,在WebView上传递
操作的HTML内容作为字符串。







编辑:



此外,您还可以尝试添加WebResourceResponse和依赖关系到你的src文件夹尝试从这里下载它们


I tried to follow this tutorial: http://docs.phonegap.com/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android

and get the following error:

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

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!

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

But how do I get it working in Android 2.2?

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

解决方案

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

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)

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

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.


EDIT:

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

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

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