Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to change the package name of an Android project?

I want to change the package name of my Android project using Android Studio from let's say, com.company.myapp to com.name.company.myapp. While there are many questions and answers that deal with renaming a part of existing package name but I couldn't find any help on how to add a new part to it.

Please help me in this regard.

Thanks

like image 365
Shahood ul Hassan Avatar asked Dec 23 '22 03:12

Shahood ul Hassan


2 Answers

Changing the application ID

(which is now independent of the package name) can be done very easily in one step. You don't have to touch AndroidManifest. Instead do the following:

1. Right click on the root folder of your project.
2. Click "Open Module Setting".
3. Go to the Default tab.
4. Change the applicationID to whatever package name you want. Press OK.

P.S. if you're using google-services.json , make sure you update new ID there too.

like image 154
Teekam Suthar Avatar answered Jan 21 '23 15:01

Teekam Suthar


Rename package name

  1. From project pane (left), click "Show option menu" it has settings like icon. Then from menu select "Compact Middle Packages"
  2. Then you will observe your main package.name folder expands. Right-click your (Package.name/ middle/ last name of your package name) expanded > Refactor > Rename
  3. Click "Do Refactor" from expanded Find tab at the bottom left of it.
  4. Finally click build.gradle (app-level), then change applicationId to 'your.new.packageName'. Then SYNC NOW
  5. Done
like image 24
saidi mmaka Avatar answered Jan 21 '23 16:01

saidi mmaka