Reputation: 213
Renaming from com.example.test to org.example.test: I have only found examples of changing the example part of this, but I need to change the com one.
I have tried Refactor then select Rename package, but I get the message Not a valid identifier name when I enter org.example.test.
Does anyone know the correct way?
Upvotes: 4
Views: 5778
Reputation: 3987
The accepted solution did not work for me. I had to do the following:
That's all. It run perfectly after that!
Upvotes: 1
Reputation: 2140
I've had to do the same a few months ago. As far as I know, Android Studio does not bound java packages with the app package. That said, you may have to change your app package (if that's what you want) and your java package.
First, your Java package
Select the 1. Project tab in Android Studio. There's a Settings button. Click on it and check Flatten Packages.
Then, select the package you want to rename. Press Shift + F6
to rename the whole package. If you have more than one package inside com.example.test
, Android Studio will warn you "Multiple directories correspond to package..." and ask if you want to rename package or directory. Choose package and it will do its magic.
Unless you have something else other than test
under com.example
, you're good to go.
Then, your Android app
For this one, I don't know any shortcuts. But if it helps, the app package is mentioned in AndroidManifest.xml
and build.gradle
for your module.
Upvotes: 0