Copying an Existing Project

If you prefer, you can use an existing project as the starting point for creating a new project. An Android Studio project is just a directory tree of files. Copying portions of that tree gives you a “new” project with all the existing content from the original one.

After copying the full tree, though, you may want to delete some existing stuff from the copy, before importing the copy into Android Studio. The items listed in the .gitignore file in the project root could be deleted. Notably, this usually means deleting:

All of those will be rebuilt when you import the project into Android Studio, with proper values for this copy.

Also, if you are copying this directory from some other development machine, delete local.properties from the project root. This contains values that are unique for your development machine, and it typically varies in content between machines.

Of course, much (if not all) of the code and layouts in the copy are unnecessary, as they pertain to the original project, not the copy. Whether you bulk-delete this stuff or selectively delete or modify what is there is up to you. Also, you will need to edit things like the applicationId in build.gradle and the corresponding package attribute on the <manifest> element of AndroidManifest.xml.

If you find yourself doing this sort of thing a lot, you might consider setting up your own “template” project that you copy from, one that has the settings you want with the least stuff needing to be edited or deleted.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.