Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change package name to existing Phonegap projects

I have an android phonegap project, and an ios phonegap project.

They were created using a given package name, but I now have to change this package name.

In Android, I think I have to change package name in manifest, plus rename/move the java file in the src folder, and change inside this java file to reflect the new package name. Then clean and build. Does this sound right?

I also noticed an option in Eclipse Android Tools >> Rename Application Package, where it asks for a package name. Would it make all necessary changes?

How would I change the bundle ID in the XCode project so the project builds ok? Just edit the Bundle identifier as explained in this ticket would do? Changing xcode package name without creating and importing to new project

Thanks for any help.

like image 987
Vero Avatar asked May 10 '13 14:05

Vero


3 Answers

It would be better if instead of Renaming the .java file and the class name, you just make your changes in:

  • AndroidManifest.xml
  • config.xml

Then remove android support with cordova platform remove android
And then re-add the android support cordova platform add android

This will generate the .java file again with the correct name.

Ref: http://intown.biz/2014/03/07/renaming-a-cordova-application/

like image 63
kumarharsh Avatar answered Oct 20 '22 19:10

kumarharsh


As a command above, just 3 steps:

  • Remove platform cordova platform remove android

  • Edit config.xml (main folder) find & replace widget id

<widget id="com.foobar.mynewname" version="1.0.0" android-versionCode="1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  • Add platform again cordova platform add android
like image 23
Guille Acosta Avatar answered Oct 20 '22 18:10

Guille Acosta


Yes, basically just change the android:package attribute in your manifest, and then refactor your src/ folders to follow that same package name.

As an alternative you can use the rename option in Eclipse, but it will have to modify all of the R.class imports in any of your java files that use resources. This will look a little intimidating, but should work fine.

like image 9
NPike Avatar answered Oct 20 '22 18:10

NPike