Online Tutorials & Training Materials | STechies.com
Register Login

Building Your First Android Application

|| 0

Building Your First Android Application
Stechies

Android Hello World Example

Please follow the steps below in order to create an Android Application: 

1) First, in the Quick Start menu, you will see some options. The first option is “Start a new Android Studio project”. So we will click this option and then give a name to your Android Application.

2) Now it’s encouraged to start the name of your application with a capital letter. For example, “My Application” or we can change this to “My First Application”, But if you start the name with small letters, you can see a small little warning here, which says the application names of most Apps begin with an uppercase so it’s encouraged to give your app name with a capital letter.

3) Also keep in mind, the company domain name. Right now, we are at the starting of our learning cycle so we will leave it at default. But in the later tutorials, you may want to change it to your personal domain name. There will also be the location, where your project will be saved, C: username Android Studio Project and the name of your project. So just click “Next”.

4) And now we are going to develop our application for phone and tablet. You can even make Android applications for TV or wearable technologies, like watches or Google Glass.

5) But in this tutorial, we will only concentrate on phone and tablet applications. And in here, this is interesting, it says the lower API level target more devices but have fewer features available. So it’s on you – how much audience you’d want to reach. So right now, by default, this Android 4.0.3 is selected, which covers 87% of all the devices. So for example, if you choose the latest version, which is Android 7.0, it covers right now almost 0% devices and if you go to KitKat, it covers only 33% of the devices. And generally, you may want to make some application which covers almost all the devices and have a backward and forward compatibility. For example, if you choose Android 2.2, it means that it will cover 100% of devices, which will run on your newer devices and on older devices. So choose the one, which covers the most percentage of devices. For example, Android Froyo.

6) Click “Next” and in here, this is the name of your blank activity and in here, you can give the name of your activity. Now, what is activity? Activity is nothing but, you can say, a section or page of your application. Similarly, if you consider or compare this activity or Android App with some website, an activity can be a homepage or About page or some other page. So an activity, you can compare to a page of a website.

7) Once everything is done, you can just “Finish”.

8) Now, this is for the first time we are running our application so we will just try to run this application and will print this “Hello World” on the running Android emulator. So for the first time, when you open this Android Studio, you can even open your Android SDK manager from here itself. There will be small Android button, which says SDK manager. You can just open this and in here, if you haven’t done your SDK manager or if you need to do some settings for SDK manager, you can open it from here itself.

9) The second button is for AVD Manager. Now AVD Manager is the full form of Android Virtual Device Manager. In this AVD Manager, you can use to set your default Android Device for which you are going to run your application. It’s going to give you a default device. So we will leave this device as default for now but you can create your own devices by clicking this create button and this we’re going to see in the further tutorials.

10) Now, in the default device, in the “actions”, we can take 3 actions. One is to launch your AVD emulator. Second is you can edit your configurations of your device so you can just click this pencil button and in here, all the settings of your device you can see. And in the “Show Advance” settings, you can even do some advance settings, for example RAM settings or VM heap or internal storage. But for now, we will leave it as default and run the application. And see if any error occurs, we will change the default RAM because sometimes whenever you, for the first time run your emulator, it gives this error.

11) So now we will just press this green triangular button, which is for running our application. Just click this. And now it’s waiting for ebd, which is abt. And now it will run or execute. Just give it a second. We only have one device, which was the default and we’ll choose that. So I will wait for this device manager to appear. So this is the launch emulator and the default device. we will just leave it as it is and click “okay”. And now, hopefully, it’ll run. But sometimes you will see it gives you some error which says that x86 emulator currently requires hardware acceleration, please ensure that HAXM is properly installed.

12) You will face an error. This is a common Android problem whenever you run your first Android application. So we don’t neeed to worry.

13) To solve the error , what we need to do is, just see the location of your SDK file, which is in the first line. So just copy this path until SDK, which will be something like C:Users your username App DataLocalAndroidsdk so just copy this path from here. And open your file manager and paste this path. And this will open your SDK folder and in your SDK folder, there will be a folder called “extras”. And in this “extras” folder, there will be a folder called Intel and in this Intel folder, there will be a folder called Hardware Accelerated Execution Manager, which has the short form of HAXM.

14) Now we will go inside HAXM and install the is an executable file there in order to install the Android emulator. So we will click this application executable file, which is Intel HAXM minus Android executable file. We will just run this. And just click “next” and this can be different for different devices. The default value of RAM can be different for different devices. If you have the larger RAM or memory, you can have more memory or otherwise depending upon the space you have.It can be 1 GB for other devices. Or it can be 4 GB for other devices. Just click “next” and install.

15) So now the installation of HAXM is complete so we will click “Finish”. And now we will close everything and we are going to run our application. So we will close the browser now and run our application once again by clicking this green button. And hopefully this time, we will not see the same error. We will choose the default application from there and wait for the message.

16) Now the application is successfully launched as HAX is working and it’s started. So now for the first time, this Android will load. This is an emulator on which, our application will run. So now Android will start or Android emulator will start and once, this emulator starts, our application is going to run on it. So it will work like an Android application or Android device. And we just need to unlock it when this is ready. So now just drag this upwards and the lock will be open.

17) And now we just need to click “okay” and you will see the “Hello World” message. So this is our application, which is running on this Android emulator.


Related Articles