简体   繁体   中英

Change android package name for phonegap project

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM