cordova android12+升级一些配置注意事项

1.以android13为例 Cordova Android 13.0.0

复制代码
cordova platform remove android
cordova platform add android@13.0.0

Cordova Android 13.0.0

这里建议将android-studio升级到最新

build时若是需要到gradled安装失败 建议多试几次 或者直接用网页下载

找到 Android Studio 的 Gradle 缓存目录: 这个目录通常是 ~/.gradle/wrapper/dists(在 Linux 和 macOS 上)或 C:\Users<用户名>.gradle\wrapper\dists(在 Windows 上),其中 <用户名> 应该替换为您的实际用户名。

2.cordova-plugin-splashscreen 对于android13 已替换

特定于 Android 的信息

从 Android 12 开始,Google 实施了一个新的 SplashScreen API,用于控制在 Android 12 及更高版本的设备上运行的应用启动动画。为了实现向后兼容性,Cordova 提供了兼容性库,该库将此功能扩展回 Android API 21 及更高版本。core-splashscreen

复制代码
<platform name="android">
    <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/splashscreen.xml" />
</platform>

Splash Screen 尺寸
自适应图标

3.在android中 themes.xml

复制代码
<?xml version='1.0' encoding='utf-8'?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <style name="Theme.App.SplashScreen" parent="Theme.SplashScreen.IconBackground">
        <item name="windowSplashScreenBackground">@color/cdv_splashscreen_background</item>
        <item name="windowSplashScreenAnimatedIcon">@drawable/icon_demo</item>
        <item name="android:windowSplashScreenBrandingImage" tools:targetApi="s">@drawable/icon_bottom</item>
        <item name="windowSplashScreenAnimationDuration">200</item>
        <item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
        <item name="android:windowBackground">@drawable/ic_cdv_splashscreen</item> <!-- 设置背景图片 -->
    </style>
</resources>

该文件中 配置了 背景颜色 icon 以及底部内容 该android:windowBackground属性在android12+不生效 同时 windowSplashScreenBrandingImage 底部图片 在android11以下也不生效 只显示一个icon

若是介意 可以在android:windowBackground该属性里 匹配好背景图 同时 在SplashScreenPlugin文件中

复制代码
        if (isFadeEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) 

加个判断 以保证在android11以下不显示icon

icon_demo的尺寸参考1024x1024

目前用的类似尺寸 ,可以在此基础上改动

icon_bottom目前我的尺寸为120x60 视情况而定

后续再加...

相关推荐
喜葵7 分钟前
前端安全防护深度实践:从XSS到供应链攻击的全面防御
前端·安全·xss
_r0bin_12 分钟前
分片上传-
前端·javascript·状态模式
东北南西15 分钟前
手写React状态hook
前端·javascript·react.js
诗书画唱16 分钟前
【前端教程】JavaScript DOM 操作实战案例详解
开发语言·前端·javascript
lypzcgf17 分钟前
Coze源码分析-资源库-删除提示词-前端源码
前端·typescript·react·ai应用·coze·coze源码分析·智能体平台
没有了遇见17 分钟前
Android 原生定位(替代高德 / 百度等三方定位)<终极版本>
android
代码青铜18 分钟前
【实战指南】Cursor前端+Zion后端:10分钟打造能收款的AI商业应用MVP
前端·人工智能
quan26311 小时前
Vue实践篇-02,AI生成代码
前端·javascript·vue.js
GIS之路1 小时前
GDAL 读取影像元数据
前端
2501_916008891 小时前
iOS 抓包工具有哪些?全面盘点主流工具与功能对比分析
android·ios·小程序·https·uni-app·iphone·webview