Building for Android 12 and 13

VoltBuilder can now build for Android 13. Here is Cordova’s blog post about the update which makes this possible.

A bit of background about confusing version numbers. This article is about building for Android 12 and 13, currently the latest versions of the Android operating system. To build for them, Android SDK Build-Tools 31 or later is needed.

Cordova has specs to build for different versions of the Android OS. This is controlled by setting the engine parameter in config.xml.

To build for Android 13, put this line in your config.xml:

<engine name="android" spec="12.0.1" />

Here is a guide to engine versions:

Engine Android OS Android SDK Notes
9.x.x 5.1-10.0 22-29 Default. No longer accepted by Google Store.
10.x.x 5.1-11.0 22-30 Only accepted for updates to existing apps.
11.x.x 5.1-12.0 22-32 Required after Nov/22.
12.x.x 5.1-13.0 22-33 Use for new apps; All apps after Aug/23.

(source: Google ) Dates )

If you need to stay on the old engine for some reason, add a line like this to your config.xml:

<engine name="android" spec="9.1.0" />

or

<engine name="android" spec="10.1.2" />

Troubleshooting

Splash tags are no longer supported.

Android 12 and later do not support the same splashscreens as earlier releases. To fix this, add these lines to your config.xml:

<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/splashTemplate.png" />
<preference name="AndroidWindowSplashScreenBackground" value="#000000" />

The first line tells Android 12 where to find the splashscreen image. The path in this example is consistent with how your project will be set up if VoltBuilder is generating splashscreens and icons automatically. If you are not doing that, you need a path to an image which is 2732x2732.

The second line sets the background colour for parts of the screen which are not covered by the image. The default is white: the second line changes it to black.

There are a number of options - start with the Cordova docs to learn more. Google has documentation on how the splash screen should be formatted.

It’s OK to leave the <splash> tags in place, so your app will also run on older versions of Android.

Get rid of the whitelist plugin

The whitelist plugin is now automatically included by Cordova in your Android build, so there is no need to have it in your config.xml. (It was never needed for iOS.)

To avoid build errors, get rid of this line:

<plugin name="cordova-plugin-whitelist" />

Obsolete plugins

Android 12 requires AndroidX be used for plugins. Not all plugins are ready for the new release.

To check if your plugins are the latest version, have a look at the log from a failed build. At the end, a table appears with out of date plugins:

Package                             Current  Wanted  Latest
Depended by
cordova-plugin-geolocation            2.1.0   2.1.0   4.1.0
cordova-plugin-network-information    1.2.1   1.2.1   3.0.0
cordova-plugin-x-socialsharing        5.4.0   5.4.0   6.0.3
cordova.plugins.diagnostic            4.0.0   4.0.0   7.1.0

If a plugin has not been updated for Android 12 (you’ll see errors in the build), it’s not something VoltBuilder can fix. You’ll need contact the maintainer of the plugin and ask them to update.

Here are plugins which have been reported to cause problems:

cordova-plugin-customurlscheme
cordova-plugin-deeplinks
cordova-plugin-file-transfer
cordova-plugin-file-transfer-ios-fix
cordova-plugin-file-downloaderphonegap-plugin-barcodescanner
cordova-plugin-local-notification (replace with cordova-plugin-local-notification-12)
cordova-plugin-x-socialsharing (replace with cordova-plugin-x-socialsharing-android12)
cordova-plugin-qr-barcode-scanner (replace with phonegap-plugin-barcodescanner-android12)
phonegap-plugin-barcodescanner (replace with phonegap-plugin-barcodescanner-android12)
phonegap-plugin-push (replace with @havesource/cordova-plugin-push)
pushwoosh-cordova-plugin
pushwoosh-pgb-plugin

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>

(Got updates to the list? Let us know! (support@voltbuilder.com)

More

For more troubleshooting tips, check out the Troubleshooting page.

For more, check out Support page.

Join Our Newsletter
Stay up to date on all of the latest news and updates for VoltBuilder