My keystore is corrupt, therefore the Android Market is requiring me to rename the app and resubmit it. However, whenever I go to edit the package names in Manifest and thro
Follow these steps:-
DONE
Without Eclipse:
Change package name and Activity names in AndroidManifext.xml and anywhere else it shows up in .xml files (custom view names, etc)
Update package import statement across all source files
Rename all folders to match the package name. Folder locations:
a. bin/classes
b. gen
c. src
Update the project name in build.xml (or your apk's name won't change)
Delete all the .class files in bin/classes/com/example/myapp/ (if you skip this step the files don't get rewritten during build and dex give a bunch of trouble processing "class name does not match path" errors
Delete gen/com/example/myapp/BuildConfig.java (I don't know why deleting BuildConfig.class in step 3a didn't cause dex to update it's path to this, but until I deleted BuildConfig.java it kept recreating gen/com/oldapp_example/oldapp and putting BuildConfig.class in there. I don't know why R.java from the same location doesn't have this problem. I suspect BuildConfig.java is auto-generated in pre-compile but R.java is not)
The above 6 steps are what I did to get my package name changed and get a successful* build. There may be a better way to handle steps 5 and 6 via dex commands to update paths, or perhaps by editing classes.dex.d in the root directory of the project. I'm not familiar with dex or if it's ok to delete/edit classes.dex.d so I went with the method of deleting .class files that I know will be regenerated in the build. I then checked classes.dex.d to see what still needed to be updated.
*No errors or warnings left in my build EXCEPT dex and apkbuilder both state "Found Deleted Target File" with no specifics about what that file is. Not sure if this shows up in every build, if it was there before I messed with my package name, or if it's a result of my deletions and I'm missing a step.
Alternative:
In Android Studio, which, quite honestly, you should be using, change the package name by right-clicking
on the package name in the project structure -> Refactor -> Rename...
It then gives the option of renaming the directory or the package. Select the package. The directory should follow suit. Type in your new package name, and click Refactor. It will change all the imports and remove redundant imports for you. You can even have it fix it for you in comments and strings, etc.
Lastly, change the package name accordingly in your AndroidManifest.xml towards the top. Otherwise you will get errors everywhere complaining about R.whatever.
Another very useful solution
First create a new package with the desired nameby right clicking on the
java folder -> new -> package.`
Then, select and drag all your classes to the new package. AndroidStudio will re-factor the package name everywhere.
After that: in your app's build.gradle
add/edit applicationId with the new one. i.e. (com.a.bc
in my case):
defaultConfig {
applicationId "com.a.bc"
minSdkVersion 13
targetSdkVersion 19
}
Original post and more comments here
Changing package name is a pain in the ass. It looks like different methods work for different people. My solution is quick and error free. Looks like no cleaning or resetting eclipse is needed.
I found the easiest solution was to use Regexxer to replace "com.package.name" with "com.newpackage.name", then rename the directories properly. Super easy, super fast.