Aah, the classic "Hello World" phrase that has been the birth the of many a programs, and indeed, programmers. To learn a new language, and to start programming in that language, you first have to create the most basic program, that is, the "Hello World" program. So continuing our Android App Development series, we figured it would be a good idea to do a small tutorial on how to create your first "Hello World" Android app. We all use, and love certain Android apps. But wouldn't it be cooler to make your own Android apps? It is, afterall, a great way to earn money!
The Android app store is growing at a rapid rate since its start. Apps is the reason why this OS is so popular. With over several hundred thousands apps, Android is one of the main players in this industry. Android app development is however a side many of us never cared or dared to approach due to its seemingly complex nature.. With the SDKs available, Android app development is not at all a hassle - rather, it's something really interesting the programmers out there. So, allow us to walk you through all the steps in creating your first Android app. You can still learn even if you're not a programmer.
Here's our Android series so far. Make sure you have set up the SDK (Part 1) before moving on wih this tutorial.
Part 2: Create Your First "Hello World" Android App
Part 3: In progress
Step 1: Setting up a new project
We have already talked about obtaining the SDK for Android Development. Now from the SDK folder, open up the eclipse.exe file, and create a new Android Application Project from the File menu.
Step 2: Project Settings
The next step is to configure your new project. Give your Application and Project a name and keep the Package name as it is. The settings shown below them need to be set carefully or your application will not work properly.
The Minimum Required SDK should be set to Android 2.3 (Gingerbread) unless, of course, you are specifically designing an app for an older OS. The Target SDK and Compile With option should be set to the latest API present, Android 4.2 in our case. As for the Theme, set it to your will.
Click on Next and you’ll come up with the app logo design, do it as you please and again go on the next page. There it would ask you about the layout of the main activity, set it to BlankActivity. Click Finish on the last window.
Step 3: Select test device
After the configurations, the actual app development begins. You can see the layout of your app in the centre of the screen. Start by selecting the target device by clicking on the small downward arrow beside the Nexus One text located on the bar right above the layout. You can select any sized device you desire.
Step 4: Adding a widget
The layout of your app would be pretty much blank right now. On the left would be a Palette tab from where you can drag and drop various objects and widgets onto the screen directly. Start by dragging the TextView onto the screen.
Step 5: Say "Hello World"!
The right most tab would be the Outline tab. Near its bottom would appear the textview’s settings after you select it from the app layout screen by left-clicking once on it. Change the third option labelled Text from 'TextView' to 'Hello World'. Ignore the warnings for now.
Step 6: Testing your app
And that’s it! Your app’s ready. Easy huh? Hello World’s are always easy. Now let’s run it on an emulator. We discussed all about Android Virtual Devices (AVDs) in the previous post). For running it on your android smartphone, go directly to Step 8.
Now from the Package Explorer tab on the left of the screen, right click on your project folder, navigate to Run As and click on Android Application.
In the previous post, we saw how to create a virtual device. If you missed that, then you can always create a new one. Select Launch a new android virtual device and then click on Manage. Click on New and set the various attributes of your emulator. Make sure the RAM and the Internal Storage are at least 512MB.
Click on OK and close the dialogue boxes.
Step 7: Choose AVD
Reopen the Android Device Chooser and now select your new AVD and click on OK. The emulator will open up and your app will automatically load up. If it doesn't, click on the Apps icon and select your app from there. You might have to wait a bit for the app to show up.
Step 8: Run on a real device!
In order to run the App on your phone, you need the .apk file which can be obtained from the bin directory in your project folder. In our case, it is at \workspace\HelloWorld\bin\HelloWorld.apk. Copy that .apk file to your Android smartphone and install from there.
Congratulations! Your Hello World Android App development process has finally been completed successfully (I hope). With a little programming knowledge, you can actually create decent apps pretty easily using this SDK. So what would be your next Android app project? Let us know in the comments section. Cheers :)
If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »
Its Amazing Qasim bro...I always like programming in C++, Java but Android is one of my finest because of Google product...Thanks for creating the first "Hello World" program.
ReplyDeleteThumbing to MBT.
Glad to know we're helping someone out :)
DeleteOn step 6 when I try to run test application it give error that
ReplyDelete[2013-09-04 06:37:56 - SDK Manager] Created AVD 'testdevice' based on Android 4.3, ARM (armeabi-v7a) processor,
[2013-09-04 06:37:56 - SDK Manager] with the following hardware config:
[2013-09-04 06:37:56 - SDK Manager] hw.sdCard=yes
[2013-09-04 06:37:56 - SDK Manager] hw.device.manufacturer=Google
[2013-09-04 06:37:56 - SDK Manager] hw.mainKeys=yes
[2013-09-04 06:37:56 - SDK Manager] hw.lcd.density=240
[2013-09-04 06:37:56 - SDK Manager] hw.accelerometer=yes
[2013-09-04 06:37:56 - SDK Manager] hw.dPad=no
[2013-09-04 06:37:56 - SDK Manager] hw.device.hash=499058361
[2013-09-04 06:37:56 - SDK Manager] hw.trackBall=no
[2013-09-04 06:37:56 - SDK Manager] hw.device.name=Nexus S
[2013-09-04 06:37:56 - SDK Manager] hw.camera.back=none
[2013-09-04 06:37:56 - SDK Manager] hw.sensors.proximity=yes
[2013-09-04 06:37:56 - SDK Manager] hw.battery=no
[2013-09-04 06:37:56 - SDK Manager] disk.dataPartition.size=1000M
[2013-09-04 06:37:56 - SDK Manager] hw.audioInput=yes
[2013-09-04 06:37:56 - SDK Manager] hw.sensors.orientation=yes
[2013-09-04 06:37:56 - SDK Manager] hw.camera.front=none
[2013-09-04 06:37:56 - SDK Manager] hw.gps=yes
[2013-09-04 06:37:56 - SDK Manager] skin.dynamic=yes
[2013-09-04 06:37:56 - SDK Manager] hw.keyboard=yes
[2013-09-04 06:37:56 - SDK Manager] vm.heapSize=32
[2013-09-04 06:37:56 - SDK Manager] hw.ramSize=1000
[2013-09-04 06:41:16 - helloworld] ------------------------------
[2013-09-04 06:41:16 - helloworld] Android Launch!
[2013-09-04 06:41:16 - helloworld] adb is running normally.
[2013-09-04 06:41:16 - helloworld] Performing com.example.helloworld.MainActivity activity launch
[2013-09-04 06:41:16 - helloworld] Automatic Target Mode: launching new emulator with compatible AVD 'testdevice'
[2013-09-04 06:41:16 - helloworld] Launching a new emulator with Virtual Device 'testdevice'
[2013-09-04 06:41:16 - Emulator] Warning: No DNS servers found
[2013-09-04 06:41:16 - Emulator] Failed to allocate memory: 8
[2013-09-04 06:41:16 - Emulator]
[2013-09-04 06:41:16 - Emulator] This application has requested the Runtime to terminate it in an unusual way.
[2013-09-04 06:41:16 - Emulator] Please contact the application's support team for more information.
[2013-09-04 06:44:12 - helloworld] ------------------------------
[2013-09-04 06:44:12 - helloworld] Android Launch!
[2013-09-04 06:44:12 - helloworld] adb is running normally.
[2013-09-04 06:44:12 - helloworld] Performing com.example.helloworld.MainActivity activity launch
[2013-09-04 06:44:12 - helloworld] Automatic Target Mode: launching new emulator with compatible AVD 'testdevice'
[2013-09-04 06:44:12 - helloworld] Launching a new emulator with Virtual Device 'testdevice'
[2013-09-04 06:44:12 - Emulator] Warning: No DNS servers found
[2013-09-04 06:44:12 - Emulator] Failed to allocate memory: 8
[2013-09-04 06:44:12 - Emulator]
[2013-09-04 06:44:12 - Emulator] This application has requested the Runtime to terminate it in an unusual way.
[2013-09-04 06:44:12 - Emulator] Please contact the application's support team for more information.
Also there is no .APK file in helloworld folder. How to save .APK?
ok brother, although there is an apk file in the bin directory, but if you are unable to locate it dont worry. There's an alternate and quite easy way of making apk of your project..
DeleteJust follow these steps and it should do:
1. right-click on your project in the solution explorer, there you'll find an option named "EXPORT".
2. Click export, a dialog will appear, select executable apk and hit NEXT
3. It will then ask you for a debug keystroke, if you already have one, browse it and enter the location, if you dont, then click "create new debug keystroke"
4. just fill in the required fields, like author name, password, alias and certificate expiry and it will generate a keystroke for you. When you are done with this, hit NEXT.
5. Now browse for your destination folder (folder where you wish to store the apk file) and you are done..
.. hope that was helpful for you.
Hussain :)
Your code seems like your project is somewhere trying to connect to a service which hasn't been declared in you manifest.xml
DeletePlease make sure whatever service you are using which involves explicit invoking, you also define permission for it in your manifest file..
Hopefully, that should fix your problem.
Hallo Qasim Brother
ReplyDeleteSumit from India, Good Idea again. But i suggest that you should start a new site for android or any other platform tutorials. It gain more users for your STC Network. & I also want to join your network.
you should give the video Demo of this..
ReplyDeleteYes that will be good .
DeleteGood idea!
Delete