Train with a trainee: Hello World App And Emulator Set Up:
First and foremost, and I can’t stress this enough, I am not a developer. I want to be though and that’s what counts. If any of the information provided in this 12 week series is incorrect or can be made simpler, please let me know.
This is the second installment of the course. All instructions assume you have done all the previous set up work from the last post. Again follow @AndroidSPIN and @openandroidmove on twitter for when a new series is up for you to view and learn from. You can also find the whole series HERE in our Forums and will be updated with each step written.
Introduction to Android and Java.
(1) Installing Android – Completed
(2) Creating Hello World –
(3) Running on Emulator -
(4) Introduction to Java Data types, Loops, Conditionals and Operators
Now that you have all your Android software and eclipse software set up, we will move to the second part of the training class which deals with the infamous (2) Hello World application and how to set up and use the (3) Emulator. All of this is pretty simple, enjoy the easy stuff. It gets much trickier soon.
Open Eclipse and select FILE > NEW> PROJECT> Android> Android Project
Fill in the blank fields with the following:
- Project name: Hello World
- Build Target: Android 2.1 update 1 (this was my choice as I have a Samsung Vibrant and this is my OS)
- Application Name: Hello World
- Package Name: com.test.hello
- Create Activity: Hello
- Min SDK Version: 5
Once all those fields are filled in you can select finished. This will create a Hello World Application for you inside Eclipse. It will look like this
If you select the Hello World folder on the Left, then src file, then your com.test.hello, then Hello.java file you will be able to see the code used to create this application.
With this example there is no coding required on our part. It is all set up and complete.
From here we can go to the top of Eclipse and select RUN > RUN AS> Android Application. This will launch the app in the Emulator. Of course this won’t happen immediately because we haven’t set up the emulator yet. It will prompt you to do this. If for some reason it doesn’t prompt you to set up the Android Virtual Device (AVD) then simply select WINDOW> Android SDK and AVD.
- Under name: Androidtest (you can name it anything you want.)
- Target: Android 2.1-update1 – API Level 7 (that is the same build target we selected to build the app with).
- SD Card: 500 MB
- Skin: Default
Now create the AVD. Now if you created the AVD after selecting RUN AS ANDROID APPLICATION you should see this screen
If you chose to run AVD first and not RUN the application first then you will see just a default android device. Like below.
Just close the AVD and click on the Hello World folder and then RUN> RUN AS>Android Application and it should load just fine.
So now you have made your first very easy very basic application. It is nothing special. What the purpose of this tutorial is more to get your tools set up and test that they are set up correctly. They also give you a glimps into how to use some of these tools. I hope everyone got the application up and running on the AVD.
A great Google resource can be found here http://developer.android.com/resources/tutorials/hello-world.html
Word of advice – I had my phone plugged in charging off my pc when I ran this for the first time. I also had my phone in Debug mode. So when I hit the run as android application my AVD didn’t pop up. The application actually installed and ran on my phone. Just a heads up.