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

后续再加...

相关推荐
n***543823 分钟前
【MySQL】MySQL内置函数--日期函数字符串函数数学函数其他相关函数
android·mysql·adb
z***75152 小时前
【Springboot3+vue3】从零到一搭建Springboot3+vue3前后端分离项目之后端环境搭建
android·前端·后端
程序员陆业聪2 小时前
Android模拟器检测全面指南:从基础到高级策略
android
fruge3 小时前
仿写优秀组件:还原 Element Plus 的 Dialog 弹窗核心逻辑
前端
an86950013 小时前
vue新建项目
前端·javascript·vue.js
2501_916008894 小时前
iOS 性能测试的深度实战方法 构建从底层指标到真实场景回放的多工具测试体系
android·ios·小程序·https·uni-app·iphone·webview
w***95494 小时前
SQL美化器:sql-beautify安装与配置完全指南
android·前端·后端
r***12384 小时前
若依微服务中配置 MySQL + DM 多数据源
android·mysql·微服务
顾安r4 小时前
11.22 脚本打包APP 排错指南
linux·服务器·开发语言·前端·flask
万邦科技Lafite4 小时前
1688图片搜索商品API接口(item_search_img)使用指南
java·前端·数据库·开放api·电商开放平台