Whenever you upgrade from a previous cordova-android or cordova-ios version, your app’s build process could introduce several unexpected errors. This guide shows how to troubleshoot your build after upgrading the Cordova platform from your app.
Upgrade your global Cordova CLI version
To upgrade to Cordova CLI 8.1.2, open a command prompt and type:
npm install -g [email protected]
Notice that 8.1.2 is the last CLI version that works with Visual Studio (with certain fixes). To install the latest cordova version use this command instead:
npm install -g cordova
Upgrade the cordova-android version from your app
To upgrade your cordova-android version, follow these steps:
- Create a ZIP backup of your app to avoid loosing important files when removing the platform, or just to keep a backup of your app with the old Cordova.
- Open a command prompt in your project’s root
- Run cordova platform rm android
- Optional and recommended: Remove Firebase-related plugins such as phonegap-plugin-push and cordova-support-google-services.
- Visual Studio developers better use the command prompt to manage plugins.
- Ensure the corresponding folder is deleted from the plugins folder
- Also make sure no references to the plugin are left in either:
- Run cordova platform add android to add a compatible cordova-android platform
- If you get critical errors when adding the platform, return to step 3 and remove problematic plugins.
- Side note: Dependant plugins such as cordova-support-google-services will be auto fetched when adding the platform.
- Run cordova platforms to check which version was installed (probably [email protected])
- Run cordova clean to resolve any plugin-related dependencies
- If your clean result is BUILD FAILED:
- Inspect the shown error messages to detect problematic plugin(s)
- Restart from step 3 and remove / update problematic plugin(s)
- DO NOT CONTINUE BELOW until you get a successfull clean output.
- Now that your clean result is BUILD SUCCESSFUL:
- Add your google-services.json file into platforms/android/app if required.
- Visual Studio developers: Jump to the Prevent error DEP10402 instructions below and continue with next step.
- Run cordova build android and check the output:
- If the build result is BUILD FAILED:
- Check if your error is something like a missing google-services.json file and address this by copying the file to the proper folder.
- Inspect the console output to isolate problematic plugins, and restart from step 3 to remove or update them with newer versions until the error is gone.
- SKIPPING TO NEXT STEP IS USELESS until you get a successful build.
- If the build result is BUILD FAILED:
- Now that your build result is BUILD SUCCESSFUL:
- Add the uninstalled plugins required, if any. Do not accept anything other than successful build outputs.
- This is a great time to upgrade your plugins individually to get newest versions.
- Visual Studio developers:
- Go to Tools > Options > Tools for Apache Cordova > Cordova Tools > Clear Cordova Cache. This task could take a few seconds.
- You can now open the solution file and compile + deploy normally.
Notice for Visual Studio fellow developers: Starting with Cordova CLI 7.1.0, whenever you deploy to emulator or device the status bar might incorrectly show Deploy failed. You should disregard this label and instead look for the INSTALL SUCCESS and LAUNCH SUCCESS messages in the console output.
The generated APK files now will be android-debug.apk or android-release.apk, and will be present in the platforms/android/build/outputs/apk folder where Visual Studio expects to find it.
Android API levels supported by cordova-android
The supported Android API Levels and Android Versions for the past few cordova-android releases can be found in the following table. Taken from Cordova’s Requirements and Support page.
The content in this post is for general information purposes only. The information is provided by the author and/or external sources and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the post for any purpose. Some of the content and images used in this post may be copyrighted by their respective owners. The use of such materials is intended to be for educational and informational purposes only, and is not intended to infringe on the copyrights of any individuals or entities. If you believe that any content or images used here violate your copyright, please contact us and we will take appropriate measures to remove or attribute the material in question.