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

后续再加...

相关推荐
然我9 分钟前
不用 Redux 也能全局状态管理?看我用 useReducer+Context 搞个 Todo 应用
前端·javascript·react.js
前端小巷子13 分钟前
Web 实时通信:从短轮询到 WebSocket
前端·javascript·面试
神仙别闹17 分钟前
基于C#+SQL Server实现(Web)学生选课管理系统
前端·数据库·c#
web前端神器23 分钟前
指定阿里镜像原理
前端
aningxiaoxixi26 分钟前
Android 之 audiotrack
android
枷锁—sha28 分钟前
【DVWA系列】——CSRF——Medium详细教程
android·服务器·前端·web安全·网络安全·csrf
枷锁—sha30 分钟前
跨站请求伪造漏洞(CSRF)详解
运维·服务器·前端·web安全·网络安全·csrf
群联云防护小杜1 小时前
深度隐匿源IP:高防+群联AI云防护防绕过实战
运维·服务器·前端·网络·人工智能·网络协议·tcp/ip
汉得数字平台1 小时前
【鲲苍提效】全面洞察用户体验,助力打造高性能前端应用
前端·前端监控
花海如潮淹1 小时前
前端性能追踪工具:用户体验的毫秒战争
前端·笔记·ux