How to create a Hello World app in Android Studio on the example of my first app.
So far I have only been playing with Android Visualizer to get the feel of how coding in Android looks. Today it’s a really important day for me because I have finally created my first Android app (which prints “Hello World!” to the screen) and successfully ran it on my Android phone.
I feel so happy right now! 🙂 Let me tell you step by step how I finally created my first app in Android Studio and how you can do that too.
P.S. I had to extend this topic to two days (eight and nine), because yesterday I only managed to do the practical part (I had two workouts and simply fell asleep after starting writing this article) and today I am focusing on describing exactly what I did yesterday during my Android app development learning session.
Installing Java and Android Studio
Fortunately for me, this process went very smoothly and didn’t encounter absolutely any problems. I read that many people get stuck at this point and had to do major troubleshooting even before they get to actually coding. Here is what I did and what I suggest you do so that you minimize the risk of any problems.
- Install any available updates to your operating system especially if you are a user of Windows. In the Menu Start, go to Settings > Windows Update (this may differ depending on the version of Windows you are using).
- Clean and speed up your operating system if you haven’t done this for a long time. I use Windows 10 and my computer has really got slower recently (Windows hasn’t been reinstalled for almost 2 years and it was initially Windows 8.1 which I upgraded to 10). I installed a couple of useful tools for speeding up the computer without doing the format (at least for now). I used CCleaner (click to go to the website where you can download it), a Polish program called Odkurzacz (in English that would be Vacuum Cleaner) and I scanned my system with my anti-virus software (I use Kaspersky and Spybot – Search & Destroy 2). After doing the above, my computer was finally ready for something more serious, that is, Java and Android Studio.
- Download and install the latest Java Development Kit. If you don’t have Java on your computer or you don’t have its latest version, go to Java SE Development Kit 7 Downloads and download the version corresponding to your operating system. It will take a few moments to install and you will be up and running. Your computer will not even have to restart (at least mine didn’t want to).
- Download and install Android Studio. The file weighs about 1.1. GB so it may take a few moments to download if you don’t have a very fast Internet connection. Follow all the instructions and use the default settings everywhere. It’s very important that you do step 3 above because without Java you won’t be able to install and use Android Studio.
That’s all for the preparation stage. Let’s now move to actually creating the first Android app!
How to create a Hello World App in Android Studio step by step
Before installing Android Studio, I was sure that creating my first app would be a lot more difficult and I would need much more time to do it. Android Studio (even though I don’t know it well yet) is quite simple to use and does tons of things for you.
All you need to do is focus on actually coding the app without the need of creating of all the companion files needed to run and test the app. That is really amazing.Here is what you need to do once you install Android Studio on your computer.
- Open Android Studio for the first time and wait until some additional components install. Choose Start a new Android Studio project.
- Now comes a very important step in which you have to name your very first app. As you can see after filling the first two form fields, a unique package name will be generated.
- Next you have to target Android devices and the version of Android. It’s recommended that you choose the version that is used on the majority of devices (so that the potential audience of your app will be the biggest possible). As you can see in the latest version of Android Studio, you can target Android Wear devices, Google Glass and even Android Auto. The suggested version of API is 15.
- Since it’s our first and very simple app in next step you simply choose the default setting, that is, Empty Activity.
In the next screen Customize the Activity, leave the default settings and hit Finish.
- Wait a few moments while Android Studio is preparing your project.
- When the process is finished you will go to the default main screen of your project in Android Studio. The Hello World app will already be waiting for you. If you want to make it more yours, you can (and should) edit the text it displays. As you can see I edited it a bit and here it’s how it looks.
As you can see my first Hello World app in Android Studio is here ready to be tested on my phone. Let’s see how it goes!
How to run a Hello World app on your Android phone
The above process is a bit similar to how I played with the code using the Android Visualizer in the browser. On one side of the screen I can edit code and on the other see the preview. However, the next (equally important) step should be to run your very first app on your phone. Here is what you need to do step by step.
- Turn on Developer options (click here to read the article on how to turn on developer options) on your phone and make sure that USB debugging is on.
- Connect your Android phone to your computer via a USB cable. Click OK when your phone asks you if you want to allow USB debugging.
- You can now install your first app on your phone and run it. Click on the green arrow and choose your phone (don’t not disconnect it from your computer).
- Wait until the installation is complete. You will see how file packages are being installed in the bottom part of the screen.
- When the process is complete, go to the app grid and your phone and look for your app! It’s very nice to see your very first app on your phone.
- Run your first app. Here is the screenshot from my phone.
I hope you didn’t encounter any problems with creating your first Hello World app in Android and the whole process went as smoothly as possible.
I am done for now and going for a 15-kilometer run before I go to work. I need to do something with these tons of positive energy in me right now.
Summary Of Day 8/9
This is really a milestone in my journey of Android app development. I successfully installed Android Studio, created my first Hello World app and run it on my phone.
What I want to say: I feel so happy. I have just become an Android developer.
Level of motivation: Extremely high
Level of fatigue: Low (even though I didn’t sleep much at night because I was thinking about my first app)
Level of experience: 0.0050%
What I have learned: I know how to create a very simple app in Android Studio and run it on an Android phone.
Share Your Thoughts
Are you an Android developer? Did you notice any errors in this post? Do you have any questions or comments?
I am only beginning my journey of becoming an Android developer and I would really like to hear from you (and learn form you). Feel free to either contact me directly or leave me your comments in the comment box below.