How to move and rename a project in android studio?

前端 未结 12 994
一向
一向 2021-02-01 15:33

This should be a really simple question :)

I have a project that works fine. Now I wanted to rename it and to change the path of the projectfolder. First it seemd simple

相关标签:
12条回答
  • 2021-02-01 15:39

    In Android Studio, I found both of the following to work OK for a project which has been copied|moved|renamed.

    Approach: Import

    1. Build > Clean Project
    2. File > Close Project
    3. Copy, Move, and/or Rename Folder
    4. Delete /old_name.iml (no longer needed)
    5. File > New > Import Project...

    Approach: Syn Project with Gradle Files

    1. Build > Clean Project
    2. File > Close Project
    3. Copy, Move, and/or Rename Folder
    4. Delete /old_name.iml (no longer needed)
    5. File > Open
    6. Tools > Android > Sync Project with Gradle Files

    Both have the same outcome.

    Import is one less step. Import is conveniently located on the welcome screen and File > New menu.

    Sync Project with Gradle Files is a somewhat more obscure menu item. However, Sync Project with Gradle Files is a good fallback if you click open when intending to Import.

    0 讨论(0)
  • 2021-02-01 15:40

    Move project files as you like and then:

    Tools -> Android -> Sync Project with Gradle Files

    0 讨论(0)
  • 2021-02-01 15:43

    I just successfully moved my C:\ project into my portable M:\ drive.

    1. Create an Identical project in the desired file path.
    2. Open original project
    3. Find the Java files on the side bar copy them all to the clipboard.
    4. Open the "new" project
    5. Paste the files in the appropriate java folder (overwrite as needed)
    6. Do the same for your activity files, pasting them to the layout folder. (overwrite as needed).
    7. Save the new project and close the application.
    8. Launch Android Studio
    9. Open your "new" project.
    10. Android Studio will ask you to choose between the original or the Project Settings.
    11. Choose the Project settings, ignoring the default settings button.
    12. Android Studio will re-build your "new" project in the new file path destination.
    13. The Emulator will appear broken, select repair device.
    14. Run your "new" project.
    15. All should be running well. (remembering that the original is still safe and sound, launching the original will take you to step 10, choose the default settings to revert to the previous state.

    I know it's a bit of a drag, but this is the only working method I have found to move a project from one destination to another and still have a viable work product.

    PS: I was searching for this query about an hour ago, with no success. After getting a positive result myself I thought I would share the result with the community... even if the thread is two years old and already marked as answered. After all, it may help the next person who is searching for a quick result, like I was.

    0 讨论(0)
  • 2021-02-01 15:49

    In Android studio 0.8.+, you can click F6 to move it.

    If you use 1.0.2 or higher, make sure you select the Project view for the Refactor -> Move menu option to become available.

    Thanks to @DavidsAlias for pointing this out.

    0 讨论(0)
  • Close the project in Android Studio (File -> Close Project). Move the project and rename it by moving its home folder/directory. Open the new project from Android Studio (File -> Open)

    0 讨论(0)
  • 2021-02-01 15:53

    What works for me:
    1. Moving Project:

    Close Android Studio .You can try to copy and paste the project normally. If there is Path error due to path to long. What I do normaly is compressing the project to rar file. copy paste to new location and extract It. For winrar use extract here as the actual root folder is inside the rar

    2. Rename the project:

    Rename the root folder to your new project name.

    3. Open In Android Studio

    Notice that when you open android studio, it will open the old project file by default. Close the project by going to File>Close Project. Then open your new project.

    0 讨论(0)
提交回复
热议问题