Allen Edwards
Allen Edwards

Reputation: 1552

How do I copy and rename a project in Android Studio

I am several hours and many unsuccessful tries into this. The first Google hit on this question is HERE which basically says copy the code into a new folder and use Refactor -> Rename to change the name.... of what?

I would expect there would be a way to change the name of a project.

I can copy the project and run it no problem. But how do I rename it? If I highlight the entire app and do refactor -> rename I can change the folder name "app" to "newName" but that does nothing. If I change the project name in the manifest, the program breaks as all the imports still have "oldName". If I manually change "oldName" to "newName" it doesn't work. If I highlight "oldName" and do Refactor -> Rename it asks if I want to change the name in my original project folder. That I am not even trying.

In searching, I find bug reports, and various methods that are incomplete like the one I linked above.

I would sincerely appreciate some help.

Upvotes: 1

Views: 6230

Answers (3)

mjginno
mjginno

Reputation: 35

And in addition to @g00glen00b answer... do a refractor of the folders inside the java folder with the same id that you wanna use.

Ex: from = com.example.azmontcort.old_app_ex

to = com.example.azmontcort.awesome_new_app_ex
which has the id of: applicationId "com.example.azmontcort.awesome_new_app_ex" in the gradle.

Upvotes: 0

Vinothkumar
Vinothkumar

Reputation: 21

Simple...

  1. Copy and rename your project folder

  2. Open your copied project in android studio

  3. Change applicationId in build.gradle (Module:app)

  4. Change app_name in AndroidManifest.xml (if you want)

  5. Run project.

Upvotes: 2

Ryan
Ryan

Reputation: 54

When you make name changes you have to make sure you change the name in AndroidManifest.xml and the build.gradle file.

In the AndroidManifest.xml make sure the package name is correct to what you're changing it to.

In build.gradle it's the applicationId that needs to be updated to the new package name as well. This will sync your files to the new name instead of still being tied to your old files which it seems was your problem.

Upvotes: 1

Related Questions