Android Studio - How to copy a project?

lilgodwin picture lilgodwin · Mar 14, 2015 · Viewed 58k times · Source

Alright, I've done some searching and seem to be coming close to the answer I'm looking for. But for fear of messing something up with my current project (I'm a first time app developer and I'm quite pleased so far... I'd like to stay that way), I'm looking for a nice and clear step by step on how to copy a project. I know some things in certain places need to be imported/renamed but I'm not sure exactly what/where.

So, is there a good step by step on how to do this or am I missing it? If not, can someone explain it to me in detail?

EDIT: I want to copy one app project to make another app project that's very similar. I'm using Android Studio for my apps. I want to be able to use one app to make another that's just like it (with differences of course). So instead of making a new project and making all the xml/java files and adding all the images, etc. I want to be able to use what I already have and duplicate it to make another app that's totally separate from the original. I'm not using Eclipse at all, I'm using Android Studio for my apps.

Answer

Andrew picture Andrew · Sep 22, 2015

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 of the 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.