Could not find class 'android.webkit.WebResourceResponse' when running HelloCordova on Android 2.2

后端 未结 1 1925
夕颜
夕颜 2021-02-14 06:59

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 e

相关标签:
1条回答
  • 2021-02-14 07:28

    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

    0 讨论(0)
提交回复
热议问题