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 视情况而定

后续再加...

相关推荐
十里-2 分钟前
在 Vue2 中为 Element-UI 的 el-dialog 添加拖拽功能
前端·vue.js·ui
shada7 分钟前
从Google Chrome商店下载CRX文件
前端·chrome
马 孔 多 在下雨13 分钟前
安卓开发popupWindow的使用
android
asfdsfgas14 分钟前
从 SSP 配置到 Gradle 同步:Android SDK 开发中 Manifest 合并冲突的踩坑记录
android
左耳咚22 分钟前
项目开发中从补码到精度丢失的陷阱
前端·javascript·面试
黑云压城After34 分钟前
vue2实现图片自定义裁剪功能(uniapp)
java·前端·javascript
zhaoyufei13334 分钟前
RK3399 11.0关闭调试串口改为普通RS232通信串口
android·驱动开发
芙蓉王真的好138 分钟前
NestJS API 提示信息规范:让日志与前端提示保持一致的方法
前端·状态模式
消失的旧时光-194343 分钟前
Kotlin 协程最佳实践:用 CoroutineScope + SupervisorJob 替代 Timer,实现优雅周期任务调度
android·开发语言·kotlin
dwedwswd1 小时前
技术速递|从 0 到 1:用 Playwright MCP 搭配 GitHub Copilot 搭建 Web 应用调试环境
前端·github·copilot