Cordova + Ionic framework - How to safely change p

2019-03-14 06:06发布

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.

4条回答
Rolldiameter
2楼-- · 2019-03-14 06:37

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楼-- · 2019-03-14 06:38

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.
查看更多
The star\"
4楼-- · 2019-03-14 06:49

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.

查看更多
家丑人穷心不美
5楼-- · 2019-03-14 06:55

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,

查看更多
登录 后发表回答