How to move and rename a project in android studio?

前端 未结 12 964
一向
一向 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:56

    This is what I do to copy/move a project. I am using Android Studio version 2.3.2

    1. Copy entire project directory to desired location
    2. Rename project directory to whatever you choose
    3. In the new project, find the workspace.xml file and manually update. Mine is located in the /.idea folder of the main project directory.
    4. When you are done changing statements in workspace.xml, start android studio and open an "Existing Project." Select Build/Rebuild and rebuild project.

    Here are some example statements that need to be changed:

    <entry file="file://$PROJECT_DIR$/app/src/main/java/com/NEW_SITE_NAME/NEW_SITE_PACKAGE)/MainActivity.java">
    
    <option name="name" value="NEW_ROOT_DIRECTORY_NAME" />
    
    <option name="KEY_STORE_PATH" value="C:\... YOUR KEYSTORE PATH ...\keystore.jks" />
    
    <option name="KEY_ALIAS" value="newrootdirectoryname" />
    
    <option name="name" value="NEW_ROOT_DIRECTORY_NAME" />
    

    There are other statements and many statements are identical. You should be able to get the idea. The key to doing this correctly is using the same naming methodology already in place in the existing workspace.xml file. If you utilize search and replace this is fairly simple process and takes only a few minutes.

    Hope this helps someone!

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

    To move the project in your filesystem using Android Studio 1.1.0:

    • Close the project in Android Studio (File -> Close Project)
    • Move the project folder to desired location
    • Import the project into Android Studio (File -> Import Project...)
    0 讨论(0)
  • 2021-02-01 15:58

    In Android studio 1.5

    1. Choose the project level view hierarchy.
    2. choose the project folder example com.example.app1 and right click -> Refactor -> move... or F6.
    3. check Move package 'com.example.app1' to another package and it may generate warning just choose OK and enter your new path for example 'com.hi.app2' and click ok and it will ask for create a new folder choose ok.
    4. close project from File -> close project
    5. choose open exiting Android studio project
    6. just Delete the all old folders for example here example and app1.
    7. Clean and Rebuild project.

    This will update move and rename the project path.

    0 讨论(0)
  • 2021-02-01 16:00

    For Android Studio 3, it seems this should be enough:

    1. Move/rename project outside of Android Studio.
    2. Tools -> Android -> Sync Project with Gradle Files
    3. Build -> Rebuild Project

    I could not deploy to the emulator after moving and renaming a project. Doing the steps above solved it.

    0 讨论(0)
  • 2021-02-01 16:00

    For Android 3.3.2+

    1. Set your project to the project menu
    2. Select the folder name
    3. In the top menu bar Refactor > Move

    Be sure to select the folder with the project name

    1. Select the directory you want to move to and confirm the move
    2. Close all projects and Import > (moved project)
    3. Uninstall the app from your device

      Important!!

    4. Turn off Instant Run to avoid the apk install process from looking for existing slices (the cache clean does not do this, apparently). This is from the SO answer here. File > Preferences > Build, Execution,Deployment > Instant Run > Uncheck the enabled box

    5. Top menu bar -- File > Invalidate Caches / Restart (I invalidate only)

    6. Run the app 10.You can now turn Instant Run back on in Preferences.

    That should do the trick

    0 讨论(0)
  • 2021-02-01 16:03

    In my case, after moving the project to another folder what worked was:

    1. Build -> Rebuild Project
    2. File -> Invalidate Caches / Restart...
    0 讨论(0)
提交回复
热议问题