I tried the two top-voted solutions but found some issues even though both work to some extent.
- List item: The new package-drag-drop method leaves some unchanged and creates some undesired effects
- List item: The rename package only changes the last part of package name
After some experiments I found the following method works well for me.
If you just need to change the last part of package name, use the method outlined by GreyBeardedGeek, namely
Right-click on the package in the Project pane. Choose Refactor -> Rename from the context menu
If you need to change the whole package name, do the following.
Right-click on the package in the Project pane. Choose Refactor -> Move from the context menu
This will create a new package folder (when necessary) but will keep the last part of your package name as before. If you need to change the last part, do the rename accordingly.
Note also that you may need to modify package names in e.g. build.gradle, manifest, and/or any xml resource files, or even in your code if hardcoded. After all that, do Sync/Clean/Rebuild project as necessary.