1

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.

Community
  • 1
  • 1
Allen Edwards
  • 1,488
  • 1
  • 27
  • 44

3 Answers3

2

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.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
1

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.

Ryan
  • 54
  • 2
  • 3
  • I made these two changes and now every activity is in error because it cannot find the package. error: package does not exist. I did a refractor -> rename on the package and that did not help. – Allen Edwards May 14 '15 at 21:02
  • With a refactor of to and the change to build.gradle this is working. Thank you – Allen Edwards May 14 '15 at 21:11
  • Oh yeah, I assumed you'd do the refactor first, glad it's working though – Ryan May 14 '15 at 22:00
  • @Ryan Made all the changes as mentioned and app also working fine but, my new app replaces the old while running on emulator(which means uninstall the old project and installing the new project) and viceversa. why its happening like this – Shiva Apr 03 '18 at 12:36
0

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.

mjginno
  • 35
  • 1
  • 5