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

1.以android13为例 Cordova Android 13.0.0

复制代码
cordova platform remove android
cordova platform add [email protected]

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

后续再加...

相关推荐
鹅鹅鹅呢5 分钟前
mysql 登录报错:ERROR 1045(28000):Access denied for user ‘root‘@‘localhost‘ (using password Yes)
android·数据库·mysql
在人间负债^8 分钟前
假装自己是个小白 ---- 重新认识MySQL
android·数据库·mysql
Unity官方开发者社区16 分钟前
Android App View——团结引擎车机版实现安卓应用原生嵌入 3D 开发场景
android·3d·团结引擎1.5·团结引擎车机版
110546540117 分钟前
11、参数化三维产品设计组件 - /设计与仿真组件/parametric-3d-product-design
前端·3d
爱笑的林羽22 分钟前
Mac M系列 安装 jadx-gui
前端·macos
运维@小兵29 分钟前
vue使用路由技术实现登录成功后跳转到首页
前端·javascript·vue.js
肠胃炎30 分钟前
React构建组件
前端·javascript·react.js
酷爱码37 分钟前
HTML5表格语法格式详解
前端·html·html5
hello_ejb339 分钟前
聊聊JetCache的缓存构建
java·前端·缓存
堕落年代43 分钟前
SpringSecurity当中的CSRF防范详解
前端·springboot·csrf