Cordova + Ionic framework - How to safely change package name?

二次信任 提交于 2019-12-20 09:47:45

问题


i would like to change default name of the installation package from default com.ionicframework.starterto com.something.something, how can i do it safely please? What i should to edit?

Thanks for any advice.


回答1:


You should make this change in the config.xml found at the root of your project. For example you might have something like this:

<widget id="com.ionicframework.exampleproject223738" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

Change the id to whatever you wish your package to be and it will work for the entire project, Android and iOS.

However, if you've already submitted to the app store with a package name, you cannot change the package name at this point. Not unless you want to submit a new project. Updates must be made with matching package names.

Regards,




回答2:


All I did was: a) Go to MainProjectFolder -> config.xml and find the line which says

<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

b) Change the io.ionic.starter to com.myproject.mobile (reverse domain - that's what they call it, right)
c) Save the file.
d) Delete the platforms folder.
e) Open the command prompt and
- platform add android
- build android
-> build --release android
-> generate key using keytool
-> sign the apk using jarsigner
-> optimize the code using zipalign (for great documentation on these commands, refer: https://ionicframework.com/docs/v1/guide/publishing.html.
f) This process takes the package name from the config.xml file and build the apk from scratch thus eliminating the need for resetting any plugins as suggested. But I am new to this. May be there are other implications which experienced guys might point at. But this worked very well for me and I have deployed my first mobile app onto Google Playstore successfully.
Hope this helps.




回答3:


This is what I did,

  1. Change the package name in config.xml
  2. enter "ionic repair"

That's it.

It removes/adds platform, removes/adds node packages and does other stuff, but everything will be automatic.




回答4:


Changing the package name in config.xml is the first step, there are other steps that need to be done to address the op's question about 'safely' changing the package name.

@ananth has given the practical answer. However it can be further simplified as I have tested and verified on Ionic 3.

  1. Change package name in config.xml
  2. Delete a platform, ionic cordova platform rm <platform>
  3. Add the platform back, ionic cordova platform add <platform>
  4. If the platform was Android, regenerate the signing key. This page (https://forum.ionicframework.com/t/how-to-automatically-sign-android-applications-with-the-ionic-cli/87449) gives the simplest and safest process.



回答5:


One should just update the package name in config.xml and reinstall all the plugins ionic state reset -- plugins ; caution ensure all the plugins are listed in package.json.



来源:https://stackoverflow.com/questions/27346127/cordova-ionic-framework-how-to-safely-change-package-name

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