Copy existing project with a new name in Android Studio

后端 未结 19 2161
野趣味
野趣味 2020-11-29 17:31

I would like to copy my Android project and create a new project from the same files just with a different name. The purpose of this is so I can have a second version of my

相关标签:
19条回答
  • 2020-11-29 17:32

    This is a combination nt.bas's answer and step 9 of Civic's answer with visual examples because it took me a while to find out what was intended since I am new to Android Studio. It has been tested in Android Studio 3.2.1.

    1. Open the project you want to clone in Android Studio. (In this example, the old project name was test5 and the new project name was test6)

    2. In the left file-overview pane, click: Project (where it might currently say android).

    1. Right mouse button click on the project within the file explorer pane and click refactor>clone.

    1. Change the "New name" to your new project name and click ok.

    1. File>open>New window>Select your new project>Open in new project window. In the new window, wait until the bottom line of Android studio is finished/says:"Gradle Sync Finished".

    1. In the file overview pane and right mouse button click (RMB) on: app.java/< your old project name (not the test one, not the androidTest one, just the blank one)>

    1. Enter the new name of your package and select both checkmarks, click refactor.

    1. In the bottom left bar click "Do refactor".

    1. Open app/res/values/strings.xml and change name of the old project (e.g. test5) to the new name of the project in line:

      <string name="app_name">test5</string>
      

    1. Open Gradle scripts/build.gradle (Module:app) and change the line to the same line with your new project name:%fig4

      applicationId "com.example.a.test5"    
      

    1. A yellow line will appear at the top of your code pane, requesting gradle sync. Press "sync now".

    1. in top bar, press build>Clean project.

    1. If it says "Gradle build finished" in the bottom left, you click "Build>Rebuild project".

    1. Now you should be able to compile and run your project again (if it worked in the first place).
    0 讨论(0)
  • 2020-11-29 17:32

    When refactoring the package name in Android Studio, you may need to click the little cogwheel up to the right by the package/android/project/etc - navigator and uncheck 'compact empty middle packages' in order to see each part of the package name as an own directory. Then for individual directories do refactor.

    This is important if you need to change all parts of the package name. For example, from com.example.originalproject to org.mydomain.newproject. Otherwise, the refactor/rename operation will only let you change "originalproject" to "newproject", and it will leave "com.example" unchanged. There is a good video that shows this: https://www.youtube.com/watch?v=dMK-RBVLeIY

    0 讨论(0)
  • 2020-11-29 17:34

    I'm using Android 3.3 and that's how it worked for me:

    1 - Choose the project view

    2 - Right click the project name, which is in the root of the project and choose the option refactor -> copy, it will prompt you with a window to choose the new name.

    3 - After step 2, Android will make a new project to you, you have to open that new project with the new name

    4 - Change the name of the app in the "string.xml", it's in "app/res/values/string.xml"

    Now you have it, the same project with a new name. Now you may want to change the name of the package, it's described on the followings steps

    (optional) To change the name of the package main

    5 - go to "app/java", there will be three folders with the same name, a main one, an (androidTest) and a (test), right click the main one and choose format -> rename, it will prompt you with a warning that multiple directories correspond to that package, then click "Rename package". Choose a new name and click in refactor. Now, bellow the code view, here will be a refactor preview, click in "Do refactor"

    6 - Go to the option "build", click "Clean project", then "Rebuild project".

    7 - Now close the project and reopen it again.

    0 讨论(0)
  • 2020-11-29 17:38

    I'm following these steps and it's been working so far:

    1. Copy and paste the folder as used to.
    2. Open Android Studio (v3.0.1).
    3. Select Open an existing Project.
    4. Close the message that will pop up with title: "Import Gradle Projects".
    5. At left side on Android Tab go to: app -> java -> select the first folder (your project folder)
    6. Refactor => Rename... (Shift + F6)
    7. Rename Package, Select both options - Put the new folder's name in lowercase.
    8. Do Refactor
    9. Select: Sync Project with Gradle Files at toolbar.
    10. Build => Clean Project
    11. Go to app -> res -> values -> strings.xml, and change the app name at 2nd line.
    0 讨论(0)
  • 2020-11-29 17:39

    The EASIEST (and definitely the quickest) way to do requires WINRAR, 7zip or similar archiving software:

    1. Find the project folder in windows explorer - double click to open this folder.

    2. Create a new folder and name it "Backup."

    3. While still in the project folder, select all files / folders, except the "backup" folder.

    4. Right-click and select "add to archive" or "create archive" (command will be different depending on your archiving software)

    5. Name the archive and click ok.

    6. Move this archive to the "Backup" folder.

    You're Done - to open the backup archive, open "Backup" folder and right-click on the backup file. Select "Extract" or create a new folder to which the files will be extracted and hit "ok" then open the project as you normally would from Android Studio, etc.

    0 讨论(0)
  • 2020-11-29 17:41

    Go to the source folder where your project is.

    1. Copy the project and past and change the name.
    2. Open Android Studio and refresh.
    3. Go to ->Settings.gradle.
    4. Include ':your new project name '
    0 讨论(0)
提交回复
热议问题