Compared to previous updates, the transition from Capacitor 4 to Capacitor 5 involves minimal breaking changes. This guide provides step-by-step instructions for updating your project to Capacitor 5, as well as a list of breaking changes for official plugins.
Note: Capacitor 5 requires NodeJS 16 or higher, as Node 12 has reached end-of-life and Node 14 will reach end-of-life on April 30th, 2023. It is recommended to use the latest LTS version of NodeJS.
-
Install the
latest
version of the Capacitor CLI in your project: -
Run the following command to let the CLI handle the migration:
If any migration steps cannot be achieved, additional information will be provided in the terminal output. Manual migration steps are listed below.
-
If you have the VS Code extension installed, check the recommendations section of the extension to find the option to migrate your project to Capacitor 5.
Upgrading Capacitor 4 iOS Project to Capacitor 5
-
Upgrade Xcode: Capacitor 5 requires Xcode 14.1+.
-
Update .gitignore: Make the following changes to your
.gitignore
file: -
Update Assets to use a single app icon: Xcode 14 supports a single app icon of 1024x1024. Clean up your AppIcon.appiconset by removing all unnecessary sizes.
Upgrading Capacitor 4 Android Project to Capacitor 5
-
Upgrade Android Studio: Capacitor 5 requires Android Studio Flamingo | 2022.2.1 or newer due to the usage of Gradle 8, which requires Java JDK 17. Java 17 ships with Android Studio Flamingo, so no additional downloads are needed.
-
Run AGP Upgrade Assistant: Android Studio can help with some updates related to Gradle and moving packages into build files. To start, run
Tools -> AGP Upgrade Assistant
. -
Update Android Project Variables: In your
variables.gradle
file, update your values to the following new minimums: -
Update Google Services:
-
Update Gradle plugin to 8.0.0:
-
Update Gradle wrapper to 8.0.2:
-
Disable Jetifier:
-
Move package to
build.gradle
: -
Update androidScheme: In Capacitor 6,
https
will be the default setting forandroidScheme
for existing apps to better enable Capacitor applications to use the system Autofill feature. To avoid data loss as a result of this change, set the scheme tohttp
now, even if it’s the current default. -
Update Kotlin version: If your project uses Kotlin, update the
kotlin_version
variable to'1.8.20'
.
Plugin Functionality Changes
The following plugin functionality has been modified or removed. Update your code accordingly:
- Action Sheet
- Browser
- Camera
- Device
- Geolocation
- Google Maps
- Local Notifications
- Push Notifications
- Status Bar
Action Sheet
- Update the
androidxMaterialVersion
variable to1.8.0
.
Browser
- Update the
androidxBrowserVersion
variable to1.5.0
.
Camera
- For Android 13, add the read media images permission (
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
) inAndroidManifest.xml
. - Update the
androidxMaterialVersion
variable to1.8.0
. - Update the
androidxExifInterfaceVersion
variable to1.3.6
.
Device
- Change
DeviceId.uuid
toDeviceId.identifier
. - On iOS 16+,
DeviceInfo.name
will return a generic device name unless you add the appropriate entitlements.
Geolocation
- Update the
playServicesLocationVersion
to21.0.1
.
Google Maps
- Update the following variables:
googleMapsPlayServicesVersion
to18.1.0
.googleMapsUtilsVersion
to3.4.0
.googleMapsKtxVersion
to3.4.0
.googleMapsUtilsKtxVersion
to3.4.0
.kotlinxCoroutinesVersion
to1.6.4
.androidxCoreKTXVersion
to1.10.0
.kotlin_version
to1.8.20
.
Local Notifications
- For Android 13, a new runtime permission check is required to schedule local notifications when targeting SDK 33. Call
checkPermissions()
andrequestPermissions()
accordingly.
Push Notifications
- For Android 13, a new runtime permission check is required to receive push notifications when targeting SDK 33. Call
checkPermissions()
andrequestPermissions()
accordingly. - Update the
firebaseMessagingVersion
variable to23.1.2
.
Status Bar
- On iOS, the default status bar animation has been changed to
FADE
.
By following these steps and updating your code accordingly, you should now have successfully updated your project from Capacitor 4 to Capacitor 5. Make sure to test your application thoroughly to ensure that all features and plugins are working as expected.