Create a Hello World Android app
Android is widely used as the operating system in as many as 2.3 billion smartphones as of 2018.
Because of the sheer number of android users and the ever increasing demand of android applications for many enterprises and personal purposes, the number of android developers is also increasing.
Android Framework provides the tools that are required to build android applications to run in your android phone.
This post is aimed to help build a simple Hello World application using Android Studio. To build your android application and to emulate an android environment, Android Studio is used.
Android Studio is the official integrated development environment (IDE) for Android operating system, built on JetBrains' IntelliJ IDEA software. It is available for download on Windows, macOS and Linux based operating systems.
At first, you need to download and setup your Android Studio.
To install Android Studio in your system, follow this link.
After you have installed Android Studio and the recommended SDK packages, run the installed Android Studio program.
Android Studio |
After this window pops up, select 'Start a new Android Studio project'.
The following Window should appear.
Application details |
In this window, type the name of the application, and the company domain. Select appropriate project location. The Package name will be generated automatically according to the company domain.
Then click on the 'Next' button.
On the next window, choose 'Phone and Tablet' and appropriate target API.
Again, click on the 'Next' button.
Choosing activity |
On the above window, choose empty Activity. As we will be working on an empty activity in this case. Every activity is associated with a UI in Android.
Click on 'Next' and finally 'Finish' button.
Now comes the waiting part. Be patient, Android Studio might take a few minutes to sync your project depending on your machine.
After all the processes are finished,
Select the 'activity_main.xml' tab.
All the UI components of an Android app are defined in an XML file.
App Layout |
You can see the layout of your Hello World application in the XML tab.
Now run the app you've just built.
To run your app for the first time, in the menu bar, goto Run>Run 'app'
Or click on the triangular play button below the menu bar.
Run the app |
To run your application, you can either create your own AVD (Android Virtual Device) and emulate the android environment in your system, or use your android device by enabling USB Debugging in your android phone.
To create your own AVD, run the application. Then, in the window that pops up, click on 'Create New Virtual Device' button.
Create a new virtual device |
Choose an appropriate phone, then click on 'Next'. In the next window, choose appropriate image file (Android OS version) to download and click on 'Next'. Finally, name your virtual device and click on 'Finish'.
Wait until the Studio downloads required files to setup the AVD.
After completion, you will see your application running on the AVD you just created.
Hello World app |
Remember that running an AVD takes some time. Be patient in the process.
If you cannot create an AVD, try running the app on your mobile phone.
For official instructions on creating and managing an AVD, follow this link.
Enjoy your Hello World app!