With Android Studio, to work on a project, you can either create a new project from scratch, you can copy an existing Android Studio project to a new one, or you can import an existing Android project into Android Studio. The following sections will review the steps needed for each of these.
Creating a New Project
You can create a project from one of two places:
• If you are at the initial dialog that you first encountered when you opened Android Studio, choose the “ Start a new Android Studio project…” menu item.
• If you are inside the Android Studio IDE itself, choose File > New > New
Project… from the main menu This brings up the new-project wizard:
The first page of the wizard is where you can specify:
- The application name
- Company domain
- The directory where you want the project files to go
- The package name
- Whether you know right now if you will be using C++ or not, as part of the Android Native Development Kit (NDK) or using Kotlin.
By default, the package name will be made up of two pieces:
- The domain name that you specify in the “Company Domain” field
- The application name, converted into all lowercase with no spaces or other punctuation If this is not what you want, click the tiny “Edit” link on the far right side of the proposed package name, which will now allow you to edit the package name directly.
Clicking “ Next ” will advance you to a wizard page where you indicate what sort of project you are creating, in terms of intended device type (phones/tablets, TVs, etc.) and minimum required SDK level:
Developers just starting out on Android should only check “Phone and Tablet” as the device type. The default “Minimum SDK” value also usually is a good choice, and it can be changed readily in your project, as we will see later .
Clicking “Next” advances you to the third page of the wizard, where you can choose if Android Studio should create an initial activity for you, and if so, based on what template:
None of these templates are especially good, as they add a lot of example material that you will wind up replacing. “Empty Activity” is the best of the available options for first-time Android developers.
If you choose any option other than “Add No Activity”, clicking “Next” will advance you to a page in the wizard where you can provide additional details about the activity to be created:
“Activity Name” (the name of the Java class for your activity) and “Layout Name” (the base name of an XML file that will contain a UI definition of your activity).
The “Backwards Compatibility (AppCompat)” check-box indicates if you want to use a library known as AppCompat. We will discuss using libraries later .
Clicking “Finish” will generate your project files.
And wait for gradle to synchronise your project then you can Start Coding.
Copying a Project
Android Studio projects are simply directories of files, with no special metadata held elsewhere. to copy a project, just copy its directory.
Importing a Project
You can import a project from one of two places:
- If you are at the initial dialog that you first encountered when you opened Android Studio, choose the “Import Project…” menu item.
- If you are inside the Android Studio IDE itself, choose File > New… > Import Project… from the main menu.
Then, choose the directory containing the project to be imported.