Copy existing project with a new name in Android Studio

后端 未结 19 2163
野趣味
野趣味 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:48

    When you copy your project you will also need to delete the original remnant intermediate build (someActivity$4.class) files from the C:...\AndroidStudioProjects(project_name)\app\build\intermediates\classes\release... directories. Otherwise you will almost certainly have build failures for the new project if yo attempt to compile the copied project. Refactoring won't solve this.

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

    Perhaps this will help someone.

    For Android Studio 4.x Projects, you need following steps:

    • copy project directory to new project directory
    • from Android Studio, open new project directory
    • edit settings.gradle file by updating the rootProject.name='newProjectName'.
    • then sync gradle
    • and here you go the project is ready, and you can start updating manifest, packages, google-services.json and all other stuff
    0 讨论(0)
  • 2020-11-29 17:50

    Requirement and test on Android Studio 3.5

    Make sure your old project working properly with your existing android studio library.

    1. Copy project directory and rename folder for new project name e.g. Bramara
    2. Open your existing new project using Android Studio 3.5. After opening project complete, Navigate to 1: Project -> Project. You may seen your project only has two directory pointing to new project folder and old project folder. Close your project.
    3. Edit appl.iml on directory new project -> app -> appl.iml using text editor. Replace all old project name into new Project Name.
    4. Reopen your exising new project. Navigate to 1: Project -> Project. You may seen your project only has one directory.
    5. Navigate to 1: Project -> Packages. right click on your component -> Refactor -> Rename.
    6. A Warning message will pop up. Make sure all change will apply to new project folder! After that choose Rename packages e.g. com.dedetok.bramara.
    7. Navigate to 1: Project -> Android. Open app -> manifests -> AndroidManifest.xml. Fix Application Activity to new pakage name. Change your Application Name to a new one.
    8. Open Gradle Scripts -> build.gradle (Module: app), change your applicationId to new project, e.g com.dedetok.bramara and sync project.
    9. Clean and rebuild your new project.
    10. Your new project is ready to edit/change.

    Note: if adb run showing activity not found, edit your Run/Debug Configuration. Module should point to module application e.g. app.

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

    I had problems with this following:

    https://google-developer-training.github.io/android-developer-fundamentals-course-concepts-v2/appendix/appendix-utilities/appendix-utilities.html

    on Android Studio version: 3.3.2

    until I killed the .idea/workspace.xml file.

    $ cp -rv Testcopysource/ TestCopyDest
    $ rm TestCopyDest/.idea/workspace.xml
    $ stdio.sh & # Run Android Studio on Linux
    

    Prior to doing that Android Studio would still point to the original source folder and all renames were applied to the original source files (within Testcopysource in my example above).

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

    In Android Studio 4.0 you need only these few steps:

    • in File Manager copy the project directory and rename the new one
    • enter in it and change applicationId inside app/build.gradle
    • open the existing new project in Android Studio
    • open one class file and highlight the package name part to change (e.g. from com.domain.appname to com.domain.newappname highlight appname)
    • right click on it -> "refactor" -> "rename"
    • choose "rename package"
    • in the dialog choose "Scope: all places" and click "preview" or "refactor"
    0 讨论(0)
  • 2020-11-29 17:56

    As of February 2020, for Android Studio 3.5.3, the simplest answer I found is this video.

    Note 1: At 01.24 "Find" tab appears below. Click "Do Refactor" and continue as in the video.

    Note 2: If you have any Java/Kotlin files "Marked as Plain Text" you need to modify the package name at the top manually, i.e. package com.example.thisplaceneedstobemanuallyupdated

    Note 3: Be careful about letter cases while renaming, just as in the video.

    Note 4: If you want to update the project name on title bar of project window, modify rootProject.name = 'YourProjectName' inside "settings.gradle" file under "Gradle Scripts" directory.

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