Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advise on renaming a Android project in Android studio(Gradle based)

In my present project , I wish to rename the Android project in Android studio (0.8.9) and wish to use it hereafter. I know about 2 solutions discussed in forum. Could some one please confirm best approach and hassle free. Moreover any advice tried/tested on Android studio 0.8.9 is best.

Solutions I know about (but not sure) A.- Close the project under consideration.Copy it and rename to new name and open with Android studio.
In this case - The project .iml file still shows the old name and so does the .name file under ".idea" folder. I also get this error:

Unsupported Modules Detected: Compilation is not supported for following modules: . Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

B. Using F6 option ,but it does not copy. I think it moves the entire project, which is not the solution.

like image 509
Abhi Avatar asked Oct 13 '14 10:10

Abhi


2 Answers

The following works for me when renaming the project:

  • Close Android Studio
  • Delete the *.iml file(s) in your project's root directory
  • Delete everything in the .idea directory except workspace.xml and tasks.xml.
  • Rename your project's root directory to the new project name
  • Restart Android Studio and import the project from the renamed directory.

Note: If you don't care about losing your workspace settings (window sizes, etc.) and you don't have any tasks then you can just delete the .idea directory entirely.

like image 59
Rob Meeuwisse Avatar answered Oct 11 '22 12:10

Rob Meeuwisse


In Android 1.5.1 tested and worked:

  1. Open Project folder (you could open it through Android studio itself see this
  2. make sure Android Studio Is closed
  3. change the yourOldProjectName.iml to the new name
  4. rename the parent folder to same new name.
  5. re-open Android Studio --> File --> Open--> path to your renamed.iml
like image 45
bastami82 Avatar answered Oct 11 '22 12:10

bastami82