How to Change Widget/App ID or Package Name for each platform?

3,414 views
Skip to first unread message

Hendy Irawan

unread,
Jan 25, 2014, 11:48:23 PM1/25/14
to phon...@googlegroups.com
Hi,

By default Cordova/PhoneGap uses the widget id from www/config.xml to generate the AndroidManifest.xml containing "package" attribute.

However, in my case I already had an app in Google Play with package "com.dietyuk.android". Renaming my www/config.xml to "com.dietyuk.android" doesn't make sense for other platforms. However if I change the widget ID to a generic one, say "com.dietyuk.mobile", then I won't be able to upload the app to Google Play because the package name changes.

I tried renaming the widget ID in "platforms/android/res/xml/config.xml", however when I run "cordova/phonegap build", the ID gets regenerated using the ID from the main www/config.xml file.

How do I set the package name/ID for each target platform?

Thank you.

Hendy

Sebastian Zillessen

unread,
Jan 27, 2014, 3:05:19 AM1/27/14
to phon...@googlegroups.com
Hi Hendy,

well I use two bundle ids for our application. You can just change the value for the id in the www/config.xml file and then run your cordova build script. The only problem is, that the folder structure does not rename on changing, so you might get two Folders in your android project directory. But for me this works quit good. 


I'm using GRUNT to build, compile and rename all things in my application. So you can even use SASS and COMPASS in your build environment. I've a task for building my iOS and android application as well, and there I just replace the widget id according to my target and then run cordova build .

replace: {
      releasetest: {
        src: [
          'www/config.xml'
        ],             // source files array (supports minimatch)
        overwrite: true,
        replacements: [
          {
            from: /widget id="[A-Za-z]+\.[A-Za-z]+\.[A-Za-z]+"/i,     
            to: 'widget id="de.some.sometest"'
          }
        ]
      },
      releaseios: {
        src: ['www/config.xml'],          
        overwrite: true,
        replacements: [
          {
            from: /widget id="[A-Za-z]+\.[A-Za-z]+\.[A-Za-z]+"/i,   
            to: 'widget id="de.some.ios"'
          }
        ]
      },
      releaseandroid: {
        src: ['www/config.xml'],             
        overwrite: true,
        replacements: [
          {
            from: /widget id="[A-Za-z]+\.[A-Za-z]+\.[A-Za-z]+"/i,    
            to: 'widget id="de.some.android"'
          }
        ]
      }
    }


If you are interested to the rest of my Gruntfile I can send it to you as well.

Hendy Irawan

unread,
Jan 27, 2014, 3:13:56 AM1/27/14
to phon...@googlegroups.com

Thanks Sebastian.

I have a feeling this is common expectation and it should be handled natively by Cordova. Probably using a preference.

Would be a good feature request? :)

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/hBEyMERACps/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

hooinator

unread,
May 6, 2014, 2:49:28 PM5/6/14
to phon...@googlegroups.com
Hi Sebastian,

I'm running into the same issue. If would love to see the entire Gruntfile if you're willing to share with me.

Thanks,
Dave

Filype Pereira

unread,
Jul 2, 2014, 5:47:29 PM7/2/14
to phon...@googlegroups.com
I am using the build.phonegap.com, I was hoping you got other replies to your initial question.

Do you know if there's a way to apply different bundle ID's for different platforms through www/config.xml ?  Did you submit this as a feature?

Thanks,
Filype

Kevin Stumpf

unread,
Dec 8, 2014, 5:27:03 PM12/8/14
to phon...@googlegroups.com
When building your app with cordova, you can use the config.xml "widget" element's attributes "android_packageName" and "ios_CFBundleIdentifier" to set platform specific app ids.


- Kevin

Richard Kimber

unread,
May 18, 2015, 6:09:53 AM5/18/15
to phon...@googlegroups.com
Thanks Kevin. That saved me a lot of grief. Rich
Reply all
Reply to author
Forward
0 new messages