In previous blog post we discussed about the requirements for Android Application development using Android Studio and setup our directory structure for it.
In this post, we are going to create a project by name First App.
1. Start Android Studio by double clicking the studio.sh. Click on Run to start Android Studio.
2. After initializing, Android Studio will show Welcome Screen. From this screen you can
- Create new project
- Import existing Gradle based Android projects
- Open an existing Gradle based Android projects
- Checkout from Version Control (like GitHub, SVN, etc)
- Configure your Android Studio
- Open recently created/opened Android projects from left panel.
(adsbygoogle = window.adsbygoogle || []).push({});
From this welcome dialog, select New Project to start New Project Creation wizard.
3. Next screen would be Configure your new project. This screen have four fields
- Application Name: Name of your application (First App for this project)
- Company Domain: Domain of your company, without http and www prefix (pcsalt.com for this project)
- Package Name: As per Google’s guidelines for creating Android Applications, we should use reverse domain of our company to ignore the package name clash with other applications. So, it will be automatically generated as <reverse-domain-of-company>.<application-name> (all in lower case letters). If you want to edit it, there is edit button on right side, click it and edit the package name. After editing, click Done.
- Project Location: As we have discussed in previous post, we are going to keep all projects in
~/Documents/android_dev/workspace_as
So, if you want to put it somewhere else, you can browser to that location. By default Android Studio will create workspace in home directory by name AndroidStudioProjects.
Click Next to proceed.
4. Next screen is about setting Minimum SDK for Android App. We are going to create application for Phone and Tablet. So, select minimum SDK as per your requirement. Here, we are using API 15 Android 4.0.3 (IceCreamSandwich). Click Next to proceed.
If you need assistance for selecting minimum SDK, click on Help me choose link. It will show another screen with a list of API and cumulative distribution of API.
Clicking on any API level will show a list of changes in left panel. If application is about using specific feature, you can see from which API it is supported and select it from here.
5. In next screen, select an Activity Type. This will be launcher of the application. Launcher activity can be changed from AndroidManifest.xml. So, this will be having default configurations and code which are required most. In this screen there are 11 options:
- Add no Activity: It will create project without creating any Activity in it.
- Blank Activity: It will add an Activity with its layout (xml).
- Blank Activity with Fragment: It will create an Activity with a PlaceHolderFragment inside it and layout for both (Activity and Fragment).
- Fullscreen Activity: It will create Activity which have code for fullscreen already inside its Java.
- Google Maps Activity: It will create Activity and its layout which will have Google Maps Fragment included, and string.xml file with instruction for putting Google Maps Api access.
- Google Play Services Activity: It will create Activity and XML. This activity will have required APIs included and instruction about it in comments.
- Login Activity: This Activity will have an XML with login fields and Activity will have field validation. Error message for failed field validation. It will also provide processing layout.
- Master Detail Flow: It will create two fragments and one Activity. It would be like a list and its detail in fragments. On phone and smaller screen devices it will show only one fragment at once, but on tablet and larger screen devices like phone in landscape view, it will show list and detail fragments side by side. All default coding will be there and you have to replace the default values with your own values.
- Navigation Drawer Activity: It will have coding for navigation drawer and standard implementation with Activity, Fragment and XML layouts.
- Settings Activity: It will create settings screen for application, with coding for different screen size. Like, for mobile phones and tablets it will have different screen layout.
- Tabbed Activity: It will have implementation for tab already done with Activity, Fragments and XML layout based on your choice of tab type. Options for tab are:
- Swipe View (ViewPager)
- Action Bar Tabs (with ViewPager)
- Action Bar Spinner
We are going to create a Blank Activity. Select it and click Next to proceed.
6. This screen varies based on your previous selection of Activity type. For our First App project it will be asking for
- Activity Name
- Layout Name
- Title of Activity (for launcher activity, title name would be same as application name. However, it could be changed from AndroidManifest.xml by editing the label of <Activity> tag.
We are using default name for it. Click on Finish to start building project.
7. Project will be build using Gradle. It will do all the initializations all by itself. Wait for a while and it will present the screen with project.
Click on Run button, or Select Run>Run app from Menu to run this application. It will open Choose Device dialog. From it, select your connected android device or AVD and Run it.
This is all about creating Android Application Project in Android Studio. In next post we will discuss about directory structure of the project.