What will you learn?
- A basic introduction to Android Studio and starting a new Android Studio project and configuring its details
- Creating a new Virtual Device and deploying your project on it
Android Studio is the official integrated development environment (IDE) for Android apps. Google announced it in the I/O conference in May 2013, and since then, it has retired Eclipse. Although still in use, developers have moved to the native Android Studio for more flexibility and faster updates.
How to Download and Install Android Studio?
You can download the Android Studio bundle from the official website. The website will automatically detect your system and give you the bundle best suited for your system.
But if you still want to download other versions, perhaps to install it on a different system, then you can scroll down to the bottom of the page and find all different versions. At the time of writing this, the latest version available is V 2.3.0.
How to Configure a Project?
After completing the installation of the Studio, run the program, and you’ll get a screen similar to this.
Click on ‘Start a new Android Studio project.’ You’ll move on to a screen that asks additional details of the project.
Application Details screen:
Give your application a name under ‘Application name:’
The company domain is not of importance right now. You can write any domain. If you don’t have one, use ‘example.com.’
The package name is automatically set using your domain name and application name.
We don’t need C++ support either. You need to check this option only when using the Android Native Development Kit (NDK). This would have allowed you to develop applications using c++.
Finally, set your Project Location where it’s easily accessible, and click Next to go to the next screen.
Target Android Devices screen:
Here, we are adjusting the settings of the devices our Android app will run on.
For each major update of the Android OS, the API level is incremented. Having a lower API level will target a higher number of devices. You can select any API level. For the remainder of this course, we will be using only Phone and Tablet apps. In that, we’ll use API 21: Android 5.0 (Lollipop).
Click Next to go to the next screen.
Selecting a preloaded Activity screen:
In this section of the project configuration, we choose an Activity to be preloaded.
An activity can be defined as a page on the Android app. Like how websites have different pages, Android apps have Activities. Each activity has two files, the XML (.xml) file to design how it looks and the Java (.java) file to write code in that activity. By selecting an empty activity, all other activities can be included. This is why all our projects will start with a blank activity.
Select the Empty Activity and proceed.
Customizing the selected Activity:
Here all we are doing is describing the activity we have selected. Android Studio will provide default values [Activity Name: MainActivity] and [Layout Name: activity_main].
You can let it be as it is. Make sure to check the two options [Generate Layout File and Backwards Compatibility (AppCompat)].
What’s in the Android Studio Interface?
When you click Finish, Android Studio will start building your app. It is normal for some systems to take more than a minute to finish all processes. Once all processes are completed, you’ll get the Android Studio Interface.
Looking at the interface like this can be quite overwhelming. This is where most people turn back because there’s too much information on one screen. So, for now, I want you to focus on only the items we will be using. Here’s the screen I want you to focus on.
On the palette, we have all the elements available to design our app. All buttons, text fields, textviews, imageviews, and many more things are available to choose from. For now, click on the run button, and that will take us to an AVD manager. Here, we have to set up our virtual device. If this is the first time you are developing apps with Android Studio, this is the screen you will get.
How to set up a Virtual Device in Android Studio?
A virtual device is some space in the memory that functions as a phone. We can have multiple virtual devices with different versions of Android OS running on it. This is helpful when testing your app for backward compatibility. Multiple devices can be used to debug instant messaging applications.
Click on ‘Create New Virtual Device,’ and Android Studio will give you a lot more options to configure your Virtual Device.
AVD name is simply the name given to your virtual device. You can just let it be what it is, or give it a name to remember your configuration.
You also have to select the device to run the app on. For this example, we are using the Nexus 6 running Android 7.1.1 (Nougat). Let the remaining options be set to default and click on finish.
Perfect, now you have a virtual device set up and can use it to run the app. You might have to install the API you selected if it’s not already installed. Once everything is set, Android Studio will take about a minute and then launch your virtual device. If it doesn’t already launch your App, hit the run button again, and this time the emulator will launch the app.
This is it! We have successfully run our first app. There was no coding involved in this, but don’t fret just yet because you’ll be developing apps in no time!