2

I manage to found few of the answers here in stackoverflow. But not really suit well with my requirement which is to change from 'com.app' to 'com.company.app'

I tried this, but its only working if you want to change from com.a.app to com.b.app Android Studio Rename Package

Community
  • 1
  • 1
Mina Makhtar
  • 517
  • 1
  • 7
  • 14
  • what did you mean by not really suit well ? – John Joe Feb 27 '17 at 01:57
  • *its only working if you want to change from com.a.app to com.b.app* Nope it is not! – Charuක Feb 27 '17 at 02:10
  • 1
    Use the 2nd method - [3 methods to change package name in Android Studio](https://stackoverflow.com/questions/25848046/how-to-change-package-name-in-android-studio) – c49 Jul 15 '19 at 11:19

3 Answers3

2

Right click on package name-> select Refractor->Move(F6) then select "Move package com.app to another package" then click yes then give new package name like com.mycompany and then click Do refractor.

This will completely refactor package name in entire project.

Now you can delete the old package.

sravs
  • 330
  • 2
  • 14
0

Example: com.myapp to com.company.myapp.

Go project folder, then find folder app\src\main\com.

Create new folder named company. Then move myapp folder to company folder you just created.

Go app\build.gradle, edit line

applicationId "com.myapp" to applicationId "com.company.myapp"

Go app\src\main\AndroidManifest.xml, edit all lines contain com.myapp to com.company.myapp.

Then go all java class inside your src and rename first line packpage with your new package.

This will be difficult but will work.

Harry T.
  • 3,478
  • 2
  • 21
  • 41
0

Only need edit build.gradle, add the following code:

shell
defaultConfig{
        ...
    applicationId "com.company.app"
        ...
}

then, run it. You will find the package name is changed.

Renats Stozkovs
  • 2,549
  • 10
  • 22
  • 26
amiko
  • 109
  • 2
  • 6