cordova update android version without any loss

Deadly 提交于 2020-01-24 21:47:06

问题


I was trying to update my android version in my cordova project using this command:

cordova platform update android

But this was the response:

Using cordova-fetch for cordova-android@~7.0.0
Updating android project...
(node:4188) UnhandledPromiseRejectionWarning: An in-place platform update is not supported. 
The `platforms` folder is always treated as a build artifact in the CLI workflow.
To update your platform, you have to remove, then add your android platform again.
Make sure you save your plugins beforehand using `cordova plugin save`, and save 
a copy of the platform first if you had manual changes in it.
    cordova plugin save
    cordova platform rm android
    cordova platform add android

(node:4188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I worried if I do so, I will lose some customisations I did (like losing the app icons, splash screens and i edited a method so the keyboard is visible when the app is in full-screen mode )

Can it be done some how?


回答1:


The app icons, splash screens and other resources are outside the platforms folder. Removing and readding the android platform will only erase contents from the platforms/android folder.

You should only worry if you have manually edited something from certain platform inside the platforms folder, generally you don't need to. This practice is heavily discouraged, not by me but the Apache Cordova guides, and they are totally correct: always avoid manual edits from the platforms folder, unless you are absolutely certain that there's no other way.




回答2:


Changes in app icons and splash

The app icons and splash are residing in the resources folder so if you delete your platform it won't affect anything. If you have manually added any icon make sure to put an entry in config.xml before your update.

Changes in any plugin

If you have changed any plugin then do the following steps

  • Detect the plugin for which you have changed your code.
  • Search for the plugin repo and fork it.
  • Change whatever you did it in your platform's code.
  • Push your code to GitHub.
  • Remove that plugin(cordova plugin rm <plugin_id>).
  • Add the plugin (cordova plugin add https://github.com/xxxxxx/xxxxxxxx). (If you think your method will be helpful for others' then you can also raise a PR in the parent plugin)


来源:https://stackoverflow.com/questions/58471949/cordova-update-android-version-without-any-loss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!