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

后端 未结 5 1327
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 06:37

i would like to change default name of the installation package from default com.ionicframework.starterto com.something.something, how can i do it safe

相关标签:
5条回答
  • 2021-02-02 06:49

    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.

    0 讨论(0)
  • 2021-02-02 06:52

    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,

    0 讨论(0)
  • 2021-02-02 06:59

    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.

    0 讨论(0)
  • 2021-02-02 07:04

    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.
    0 讨论(0)
  • 2021-02-02 07:05

    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.

    0 讨论(0)
提交回复
热议问题