The Google Play Store is updating the target API level requirements. All app submissions will be required to target Android 12 (API level 31) or higher.
New App Submissions: Starting on August 1, 2022, new apps must target API level 31 (Android 12) or above and adjust for behavioral changes. Wear OS apps must target API level 28 or higher.
App Updates: Starting on November 1, 2022, app updates must target API level 31 or above and adjust for behavioral changes in Android 12.
Cordova users need to update to cordova-android v11 in order to support these new Play Store requirements. There are some breaking changes related to Splash Screens.
To perform the update first remove and add the android platform:
ionic cordova platform remove android
ionic cordova platform add android@11
Additionally, in your config.xml make sure your target SDK for Android is 32:
<preference name="android-targetSdkVersion" value="32" />
During this process, you are likely to see an error related to your splash screen (see below). See cordova docs on the new Splash Screen settings in config.xml.
Removing Splash tags
Your config.xml no longer supports <splash> and you will receive this error:
The "<splash>" tags were detected and are no longer supported. Please migrate to the "preference" tag "AndroidWindowSplashScreenAnimatedIcon".
You will need to remove entries in your config.xml under platform android that mention <splash….
Then add the required preference:
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="[path to png/xml]" />
The [path to png/xml] must be a valid filename. Eg resources/android/icon/drawable-xxxhdpi-icon.png
Missing AndroidWindowSplashScreenAnimatedIcon
Your config.xml requires this addition element otherwise this error will occur:
The "AndroidWindowSplashScreenAnimatedIcon" value does not exist
This is caused by the path specified in your config.xml being incorrect. Eg: in the below example if the path specified in value is incorrect this error will occur:
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/icon/drawable-xxxhdpi-icon.png" />
At a bare minimum you should provide a png of size 2732x2732 (see requirements). You can enhance this later using launch storyboard images.
Cannot Set Properties of null
You may get the following error during the platform add android operation:
Cannot set properties of null (setting 'text')
This error can occur when you have specified a valid file path for the AndroidWindowSplashScreenAnimatedIcon value. This can be caused if you have added the following to config.xml:
<resource-file src="resources/android/colors.xml" target="app/src/main/res/values/colors.xml" />
<color name="cdv_splashscreen_background">#FFFFFF</color>
Cordova on a Mac M1
If running into the error during building for android:
General error during conversion: Unsupported class file major version 61
This can be caused by the JDK version installed. Open JDK 11 with arm64 (Mac M1 / Silicon) support can be downloaded from here be sure to select "aarch64" for the Architecture. After installation you may need to set your JAVA_HOME to point to the installed JDK location (eg
Build Tools Version 32
No installed build tools found. Please install the Android build tools version 32.0.0
Duplicate allowBackup
The following error may occur during build related to allowBackup:
Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:5:18-45
is also present at [:br-android-vault:] AndroidManifest.xml:10:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:5:5-62:19 to override.
Remove the following line from config.xml:
<application android:allowBackup="false" />
Then remove and re-add the platform
ionic cordova platform remove android
ionic cordova platform add android@11
Android:Exported must be set
The following error can occur during build:
android:exported needs to be explicitly specified for element <activity#your.bundle.id.MainActivity>.
Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`
when the corresponding component has an intent filter defined.
See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
In config.xml add the following:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
<application android:exported="true" />
</edit-config>
Incompatible Cordova Plugin Diagnostics
The following error can occur when using cordova-plugin-diagnostics v5:
Diagnostic_Notifications.java:35: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
Install at least version 7.1.0 to resolve this:
Common Migrations
The following are common migrations that are needed for older Cordova projects to be updated to Cordova-Android 11:
Remove Splash Screen Plugin
The Splash Screen plugin is built into Cordova now so remove it:
cordova plugin remove cordova-plugin-splashscreen
Remove Android X Plugins
The plugin cordova-plugin-androidx is not required as it is built in so remove it:
cordova plugin remove cordova-plugin-androidx
The plugin cordova-plugin-androidx-adapter is not required as it is built in so remove it:
cordova plugin remove cordova-plugin-androidx-adapter
Note: The plugin phonegap-plugin-push has a dependency on cordova-plugin-androidx-adapter. The plugin is deprecated and you should migrate to @have-source/cordova-plugin-push to get better support.
Enabled AndroidX
The preference for AndroidX should be true in config.xml:
<preference name="AndroidXEnabled" value="true" />
Remove Whitelist Plugin
The plugin cordova-plugin-whitelist is built into Cordova and should be removed:
cordova plugin remove cordova-plugin-whitelist
Upgrade Node
Node 12 is no longer supported. As of August 2022 the LTS (Long Term Support) version of Node is v16 and should be the minimum version used.
Upgrade NPM
It is common that NPM is also not updated and the usual issue is that peer dependencies are not handled correctly. Check the version you are using with npm -v and upgrade to at least version 8 of npm:
npm install npm -g
Upgrade Identity Vault
Versions below 5 of Identity Vault will not work with Android 12. They will get the following error:
Could not find method compile() for arguments [android.arch.lifecycle:extensions:1.1.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
Upgrade Identity Vault to v5 to resolve this issue (making sure to remove the implementation of browser vault as v5 has this built-in).
App Flow Users
Note: For App Flow Users. Be sure to use the Linux 2022.07 (or higher) build stack which support Cordova Android 11.
Comments
6 comments
Hi, excellent article, it helped me a lot because I was going through the same problem for days, I followed your entire article, but I'm having an error when adding the android platform
Cannot read properties of null (reading 'find')
Can you help me please, i don't know what it means
The problem is very specific to your project and could be related to plugins used, how you manipulate resources in config.xml. I would remove anything in your config.xml that has <resource-file in it to narrow down where the project is getting messing up.
The problem is in splash
here the error:
and the file wich raise the erro is:
on the find() funtion on foreach, do you know whats happining?
Thanks bro! This is what i was searching for 🤙
A good place for a discussion on issues updating to Cordova Android 11 is either the Ionic Discord server or the Ionic forum. If your company wants more detailed help then our Advisory services are what you are after, we often get on Zoom calls to troubleshoot code.
Aishwarya, you are missing a space between activity and android in the line: <activityandroid:exported="true"/>
Article is closed for comments.