问题
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.
回答1:
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.
回答2:
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/
回答3:
As a command above, just 3 steps:
Remove platform
cordova platform remove androidEdit 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
回答4:
The files containing the project name are:
- AndroidManifest.xml <-- package name
- res/values/strings.xml <-- visible name in list
- build.xml
- config.xml
Go into src/your.project.name and open the .java file.
Under the license change the package name to the new package name to whatever you desire.
Use the same package name in AndroidManifest.xml "Package".
Attempt build and if that works then Modify the value in res/values/strings.xml.
Build again and go through each value until you are happy.
回答5:
in ios all you have to do is to change the config.xml attribute
<?xml version='1.0' encoding='utf-8'?>
<widget id="org.test.area" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>YourNewAppName</name>
[...]
then as kumar suggested do a cordova platform remove ios then cordova platform add ios and cordova build ios then rebuild the project in xcode!
来源:https://stackoverflow.com/questions/16484451/change-package-name-to-existing-phonegap-projects