Building for Android 12
VoltBuilder can now build for Android 12. 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, currently the latest version of the Android operating system. To build for it, 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 12, put this line in your config.xml:
<engine name="android" spec="11.0.0" />
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 for new apps; All apps after Nov/22.|
(source: Google )
Splash tags are no longer supported.
Android 12 does 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.
It’s OK to leave the
<spash> 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" />
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-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) 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! (firstname.lastname@example.org)
For more troubleshooting tips, check out the Troubleshooting page.
For more, check out Support page.