Android Studio - How to copy a project? Android Studio - How to copy a project? android android

Android Studio - How to copy a project?


I'm a newcomer to Android and AndroidStudio (AS) and I've laboured for many hours trying to use AS to 'clone' a project. Many thanks for the existing answers given above that set me on the right path. For any total newbie's, like myself, the following detailed step-by-step instructions should prove useful:

  1. Using Windows Explorer, navigate to the Android Studio projects directory select the project folder to be cloned;

  2. Copy the selected folder;

  3. Paste the folder into the Android Studio (AS) projects directory;

  4. Rename the pasted folder to be the new name of the cloned project,say 'ViewPager_Shell';

  5. Launch Android Studio;

  6. Select 'Open an existing Android Studio project';

  7. Navigate to the AS projects directory;

  8. Select the folder 'ViewPager_Shell';

  9. Ensure that AS's explorer pane is visible on the left-hand-side ofthe AS main frame;

  10. Select the 'Android' view for the explorer pane;

  11. Open app -> java; the old package name should now be visible, e.g. 'com.hulme.owm';

  12. Right-click on the old package name and select 'Refactor -> Rename';

  13. A dialog should now appear; left-click 'Rename Package';

  14. In the pop-up dialog, replace the old package (e.g. 'owm') with the new package name (e.g. viewpager_shell);

  15. Left-click on the 'Refactor' button; BEWARE!! ... A new 'Find Factoring Preview' pane should open in the lower-left of the AS main frame window;

  16. Select 'Do Refactor';

  17. Using the AS explorer pane, navigate to 'Gradle Scripts -> build.gradle(Module:app);

  18. Double-click build.gradle(Module:app) to view its contents in the AS editor pane;

  19. Change the defaultConfig 'applicationID' string to your new full package path (e.g. "com.hulme.viewpager_shell");

  20. Using the AS explorer pane, navigate to 'app -> manifests -> AndroidManifest.xml';

  21. Double-click on 'AndroidManifest.xml' to view it in the AS editor pane;

  22. Under the manifest tag, you should observe that the new package name (e.g. 'com.hulme.viewpager_shell') now appears, as a result of the previous refactoring step;

  23. Under application tag, change android:label to a new name (e.g. "ViewPager Shell Demo") - this is the name that appears in the list of installed apps provided by Android's 'Settings -> Application manager;

  24. Under activity tag, change android:label to a new name (e.g. "VP Shell") - this is the name that appears under the app's icon and it is also the activity's default ActionBar title;

  25. You should now be able to build and run the newly cloned project.


To achieve your objective follow the below steps:

  1. Close the existing project by navigating to File-> Close.
  2. Find out your Android Studio workspace path and Navigate to that path.
  3. In that directory you will have this project. Make a new folder and copy the contents of this folder to that new folder. orCopy the existing and project folder and paste it where ever you want and then rename it.

  4. Go to Android Studio, select Import Existing project, select the new folder from the path you have stored it.

This must be sufficient to achieve your objective. Hope this might help you.


STEPS FOR CREATING AN ANDROID STUDIO PROJECT FROM ANOTHER PROJECT
(Tested multiple times as of version 2.3.3)


  1. Close Android Studio
  2. Navigate to projects directory and find the project folder you wish to replace
  3. Copy the project folder, paste in the same directory and rename (no spaces)
  4. Open Android Studio, opening copied/new project
  5. If prompted to remove Gradle import from the project, leave checked and click ok.
  6. Under app, res, values, open strings.xml and update the app name. You will likely come back here to edit further strings to fit your new app.

    1. In MainActivity.java, highlight the part of the package name that needs to be changed (usually the last part after the period, e. g. in the package net.androidbootcamp.concerttickets you would select concerttickets).

    2. Right-click on selection and choose refactor, then rename.

    3. When prompted to rename package or rename directory, first choose rename directory, leave comments checked and proceed.

    4. Be patient until the bottom left corner says "[n] occurrences changed".

    5. Repeat steps 8-10, but this time choose rename package, then check both boxes (comments and text occurrences), and proceed.

    6. It will give you a refactor preview at the bottom, click "Do Refactor".

    7. Click the synchronize button (Ctrl+Alt+Y).

    8. Select build, clean project.

    9. Use project search and replace to double check your package names. My experience has been without issue but this is just in case. After refactoring, you may also notice that the full package name now displays as a prefix for resources in the code, for example, "net.androidbootcamp.concerttickets.R.id..." instead of just "R.id..." Either is fine but this can be quickly remedied with search and replace, as needed, for readability. If you perform this step, select build and clean project, afterward.

    10. Run app to test before modifying further.

NOTE: You may need to re-select your theme for your (internal) emulator or make other similar environment-specific changes.