Fynn
Fynn

Reputation: 208

How can i rename my package? IntelliJ

I try to upload my App into the Play Store, but Google does not allow Apps which contain packages with names like: "example.xxxxx". My problem is that my package is called "com.example.MainActivity" and I already tried to rename it, but all I can do with IntelliJ is renaming the part "MainActivity". "example" remains the same. After trying to change example by going into the manifest and refactoring it with a different name, IntelliJ just created a new package with the new name, but the old package, which is in use, still has got the same name. Could anybody help me with this problem and tell me how to change the package name correctly?

Edit: The Manifest and R files did not get copied, after renaming example. Could anybody help me how to include them? Edit2: I solved the problem with both files by just changing the package name inside the AndroidManifest.xml file.

Upvotes: 2

Views: 9584

Answers (3)

Lukasz Frankowski
Lukasz Frankowski

Reputation: 3175

Less hassle version of this action is simply to open some class and get to the package and click Shift+F6 or select appropriate position from context menu:

enter image description here

Upvotes: 3

mthandr
mthandr

Reputation: 3061

EDIT: First uncheck Compact Empty Middle Packages, then Right Click on the package in the package explorer to the left (normally) and choose Refactor > Rename. Done. Be careful to check that in the manifest it is well renamed, sometimes it doesn't refactor there.

Uncheck Compact Empty Middle Packages Uncheck

Should look like those packages

Packages

Rename package

Rename

The warning will still appear, but you should be able to rename the package.

Upvotes: 6

Fyodor Volchyok
Fyodor Volchyok

Reputation: 5683

If you want to rename empty middle package you should first expand package tree. Here is nice (though a bit outdated) example how to do that. Then you'll be able to rename desired package with refactor->rename.

Upvotes: 1

Related Questions