2

I created a new app in Android Studio, everything went fine, I created a signed apk, but I have an old app on Play Store published, I managed to locate the key.keystore for that old app, which i originally did in Eclipse two years ago, so after opening my old apk in Keystore Explorer, I was able to remember my old store password, alias and key password, so I went back into Android Studio, clicked Generate New Signed apk, I selected my old keystore path, filled in the info (store password, alias, key password, and it left me generate the new signed apk with the old key.keystore, so I'm assuming I actually got the new AS app signed with my old Eclipse key.keystore or it wouldn't have left me generate a signed apk right? or run it in emulator until I entered the correct info.

Now the next problem I'm having is renaming the package, what I need to do is rename the new app/package to the same name as the old app/package (com.name.radio) I read that you do this in the build.gradle..... When I created my new app in AS I was able to renam the 3 folders under java first with no problems (to name.ie.radio) to do this I select the folder I want to rename, click Show Options Menu, untick Compact Empty Middle Packages, right click my folder & select Refactor > Rename > Rename Package, then I had to correct that in the build.gradle, worked fine the first time.

Now I want to rename my new app / package again, to the same name as my old app (com.name.radio) so I tried setting new package name to com, but it doesn't allow me, saying that file already exists. https://i.stack.imgur.com/cNgA5.png

Should I delete the com folder at: \app\build\generated\source\r\release There's no point in trying to rename it in the build.gradle yet right?

Someone help me out here it's like a guessing every night. I just want to publish an update to my old app without having to publish a fresh app.

EMar
  • 61
  • 1
  • 9

3 Answers3

5

This modification needs three steps :

  1. Change the package name in the manifest
  2. Refactor the name of your package with right click -> refactor -> rename in the tree view, then Android studio will display a window, select "rename package"
  3. Change manually the application Id in the build.gradle file : android / defaultconfig / application ID Then clean / rebuild the project

according to this answer

Community
  • 1
  • 1
Stanojkovic
  • 1,612
  • 1
  • 17
  • 24
  • It won't let me refactor the package name to "com" says that file already exists. http://i.stack.imgur.com/cNgA5.png It has to be renamed to "com" as that's the name of the old app package (com.name.radio) I re-edited my post above. – EMar Oct 02 '16 at 21:45
  • 4
    I renamed the "com" directory to "org" \app\build\generated\source\r\release\com Then I was able to refactor > rename the package name to "com" – EMar Oct 14 '16 at 13:55
  • Glad you did it at the end. – Stanojkovic Oct 14 '16 at 17:38
  • Thanks yea, took a while to figure out after hours of reading. – EMar Nov 02 '16 at 23:03
1

All you need to do is delete the directory which Android Studio says is causing the problem. In this case, the ...\build\generated\source\r\release\com directory.

It will not affect your source code since this is a directory which is automatically generated when you rebuild the project.

0
com.yourdomain.yourapp

If you cant rename yourdomain, rename first the com package, then you can raname yourdomain and restore the name com

Pablo Cegarra
  • 20,955
  • 12
  • 92
  • 110