Rename a package in Android Studio

I am trying to rename my Android Studio package as described in the first answer, to: Android Studio Rename Package

Trying to change org.springframework.android.showcase to org.springframework.android.showcase2

Refactoring seems to work fine, then I try to remove the old package in /gen/org.springframework.android/showcase. This happens, but then reappears (inside / gen / org.springframework.android / showcase)

When compiling, I get more than 100 errors related to links to the R.java file.

Copying the R.java, Manifest.java file from the original to the new does not work. Studio simply deletes them, but leaves the BuildConfig.java file.

Is there an easier way because Studio just doesn't want to play ball?

Below is my project structure if useful.

enter image description here

+3
source share
4 answers

The reason you see the generated files with the old package name is because you only renamed the source package. The generated files use the package name defined in AndroidManifest.xml. If you also modify the package at the top of the manifest, you will see that the generated files use the new package. Be sure to clean the project and rebuild it to see the changes.

+15
source

Try the menu: build->clean project

+1
source

Android Android- . .

And click "Open module settings." Or use the shortcut key F4. Go to the Flavors tab. Rename the application ID of your choice - this is your new package name.

Source: http://wazeem.com/639/how-to-rename-package-in-android-studio/

0
source

For me, the package name has been renamed to Android Studio everywhere except manifest.xml. I manually replaced it there, and then compiled it.

0
source

All Articles