一、下載
webview下載地址,感謝火哥分享,版本很全。https://www.firepx.com/app/android-system-webview/
二、更新
external/chromium-webview/prebuilt具體更新那個目錄,需要查看編譯架構
這個看你的lunch就行,這里我的是arm64,所以我下載最新webview最新apk后更改名稱覆蓋即可
三、修改默認包名
frameworks/base/core/res/res/xml/config_webview_packages.xml<webviewproviders><!-- The default WebView implementation --><!-- <webviewprovider description="Android WebView" packageName="com.android.webview" availableByDefault="true"> --><webviewprovider description="Android WebView" packageName="com.google.android.webview" availableByDefault="true"></webviewprovider>
</webviewproviders>
四、編譯一致性問題
編包可能會碰見可選依賴庫error,導致編譯失敗,這里在bp文件中加入如下代碼即可。相關文章
https://blog.csdn.net/dongxianfei/article/details/123665498
//
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//// Install the prebuilt webview apk.
package {default_applicable_licenses: ["external_chromium-webview_license"],
}// Added automatically by a large-scale-change
// See: http://go/android-license-faq
license {name: "external_chromium-webview_license",visibility: [":__subpackages__"],license_kinds: ["SPDX-license-identifier-Unicode-DFS",],// large-scale-change unable to identify any license_text files
}android_app_import {name: "webview",product_specific: true,default_dev_cert: true,required: ["libwebviewchromium_loader","libwebviewchromium_plat_support",],arch: {arm: {apk: "prebuilt/arm//webview.apk",},arm64: {apk: "prebuilt/arm64/webview.apk",},x86: {apk: "prebuilt/x86/webview.apk",},x86_64: {apk: "prebuilt/x86_64/webview.apk",},},//新加代碼 enforce_uses_libs: false,dex_preopt: {enabled: false,},
}
五、關于特權應用使用webview報錯
只要在Activity的oncreate方法中調用hook函數就行了,切記一定要** 在setContentView之前調用** ,或者在** webVIew創建之前調用** ,不然還是會報錯的。相關文章
https://blog.csdn.net/TeleostNaCl/article/details/148400974
https://geekdaxue.co/read/xshawn@aosp/bfn7lq
https://blog.csdn.net/wxj280306451/article/details/106522384