📅  最后修改于: 2023-12-03 14:40:13.075000             🧑  作者: Mango
Cordova is a popular open-source platform for building mobile apps using JavaScript, HTML, and CSS that can be deployed to both Android and iOS. One of the major changes in Cordova 9.0 was the switch to using AndroidX libraries instead of the legacy Android Support Library. This change was done to address the incompatibility issues that existed with some of the older Google libraries that developers were using in their Cordova projects.
AndroidX is a new package structure for the Android libraries that has been developed by Google to make it easier for developers to manage dependencies and provide better support for the latest Android features. It also ensures that apps work well across different devices with different screen sizes and resolutions.
There are several reasons why developers should use AndroidX in their Cordova projects, including:
To use AndroidX in your Cordova project, you need to add the following preference to your config.xml file:
<preference name="android.useAndroidX" value="true" />
<preference name="android.enableJetifier" value="true" />
This preference tells Cordova to use AndroidX libraries instead of the legacy Android Support Library. The android.enableJetifier
preference is used to automatically modify the third-party libraries that are not updated to AndroidX. Once you have added this preference, you can run cordova prepare android
to have Cordova update your project to use the AndroidX libraries.
In conclusion, AndroidX is a new package structure for Android libraries that provides better support for the latest Android features and ensures better compatibility across different devices. Cordova 9.0 switched to using AndroidX libraries instead of the legacy Android Support Library, so it's important to update your Cordova projects to use AndroidX to ensure better performance and future-proofing. Adding the android.useAndroidX
preference to your config.xml file and running cordova prepare android
will update your project to use AndroidX libraries.