1

I have an existing project in Android Studio that for example is com.pete.mike.joe.appname. If I want to change it to com.pete.appname how would I do that? I have read about changing the androidmanifest.xml and the build.gradle file and refactoring the com.pete.mike.joe.appname values but never saw an example when you want to remove some of the dot values. Any thoughts?

Thanks.

JR

John
  • 61
  • 2
  • 7
  • Possible duplicate of [Rename package in Android Studio](https://stackoverflow.com/questions/16804093/rename-package-in-android-studio) – Roaim Sep 23 '19 at 20:09
  • I think you can follow this easiest solution, https://stackoverflow.com/a/28336365/5465447 – Roaim Sep 23 '19 at 20:14
  • Thanks for the replies. Roaim, with the one you pointed to will Google see it as the new ID? I already published a private app one time with the current application ID and Project Name so want to make sure it won't push it back saying it already exists. – John Sep 24 '19 at 13:33

2 Answers2

0

On Mac or Linux ( install perl if not installed )

  1. Take a backup of your current project , so that if in case the below command creates an issue you can use that...

  2. Go to your project root directory :-

    e.g if your project is in /home/ubuntu/AndroidProjects/MyProject then first do

    cd /home/ubuntu/AndroidProjects/MyProject

3.

find . -name '*.*' -print0 | xargs -0 perl -pi -e 's/com\.current\.package\.name/com\.new\.pacakge\.name/g'
Ahmad
  • 437
  • 1
  • 4
  • 12
0

I have an existing project in Android Studio that for example is com.pete.mike.joe.appname. If I want to change it to com.pete.appname how would I do that?

You can accomplish this by following the following 4 steps:

  1. You need to follow this answer till step 3.
  2. Then you need to drag and drop the appname directory to the pete directory.
  3. After that Android Studio will prompt you to refactor the project. You should select Move package 'com.pete.mike.joe.appname' to another package. And confirm every prompt.
  4. Finally, hit Do Refactor to automatically refactor the project.

For your convenience, I have made a video example to show you how to change the package name and at the same time refactor the entire project in Android Studio. Please have a look at the following video,

video example

Roaim
  • 2,298
  • 2
  • 11
  • 23