4

I have come to be responsible for adding push notification capabilities to a phonegap project. Things in iOS are working smoothly but Android is causing some trouble. The problem seems to be that the application package/bundle name is com.phonegap.helloworld. Urbanairship does not like a "duplicate package name", which was easily changed in xcode but not so easily changed in the android side.

I attempted the accepted answer from this question: Change package name to existing Phonegap projects that is, I changed the the 'package' field in the platforms/android/AndroidManifest.xml and then refactored the directory structure to reflect this new package. When I built the android app, however, the old directory that I'd mv'd to reflect the package name change reappeared. The AndroidManifest.xml file had also been altered so that the 'package' field was back to com.phonegap.helloworld.

So I am baffled - how do I change the package name?

Community
  • 1
  • 1
John
  • 401
  • 6
  • 13
  • You misunderstood his answer. He didn't even talk about changing the platforms/android/AndroidManifest.xml file, I'm not sure how you understood that from his post. – Stephan Branczyk Feb 11 '14 at 21:41
  • Please post your manifest file for your project on here. We'll tell you which part exactly you need to edit. – Stephan Branczyk Feb 11 '14 at 21:44
  • How else would you interpret "Yes, basically just change the android:package attribute in your manifest, and then refactor your src/ folders to follow that same package name."? – John Feb 11 '14 at 21:47
  • The platforms/android-14/ folder doesn't contain your manifest file. It contains the manifest file of the entire platform's sdk (which gets imported into your project). He only wanted you to modify your own Manifest file, not the entire platform's sdk files. Please post a screenshot of your project inside your Eclipse IDE, I think the problem is that you don't have Eclipse set up the way most people have. – Stephan Branczyk Feb 11 '14 at 22:01

1 Answers1

19

You shouldn't edit the files under platforms/ this is where phonegap creates the specific device versions based on the www directory and will overwrite them whenever you run a new build.

To edit the package name, open the config.xml file in the www directory. The package name is the value for 'id' in the 'widget' tag:

<widget
    id="PACKAGE NAME"
    version="1.0.0"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:gap="http://phonegap.com/ns/1.0"
>

Here's a link to another example.

Brian
  • 376
  • 4
  • 9
  • 2
    Not sure why this doesn't have more upvotes. I've seen many other hacks/solutions, but this is by far the best one. Change the id in the config.xml and rebuild your project. Done. – DemitryT Jul 24 '14 at 19:29
  • Thanks a lot for the simple and easy answer – jivangilad Oct 29 '14 at 13:20
  • 1
    My app's ID is different for Android and iOS. Can you do platform specific id's? – Pieter May 18 '16 at 12:26