Saturday, 16 February 2013

Android Game Development Tutorial [ Part3 ]


Hi Friends,
            Welcome you all in the Android Game Development [Part3].

            Let’s take a quick review of what we have learnt in the Android Game Development [Part2].
1)    We have learnt about how to put Emotions.
2)    We have learnt about how to create Game Level.
3)    We have learnt about how to handle Collision Detection.
4)    We have learnt how to put these things all together to create a full game.

Let’s have a look what we are going to learn in this part.
1)    How to setup Development environment for Android.
2)    How to create a “Hello World” application.
3)    How to run the application on an Android Simulator.
4)    How to port the application on an Android Device.

First of all we will setup our development environment for Android.
For that you need to download the ANDROID DEVELOPER TOOL (ADT).

You can use the following link to download the ADT :-
http://developer.android.com/sdk/installing/bundle.html

            This single bundle gives everything you need for developing apps.
1)    Eclipse + ADT plugin
2)    Android SDK Tools
3)    Android Platform-tools
4)    Simulator

Setting up the Developer Tool:-
1)    Unzip the zip file named adt-bunlde-<os-platform>.zip and save it to some location where you want to save.
2)    Move to adt-bundle-<os-platform>/eclipse/ directory and run the eclipse exe.


Create our first Android Project:-

The steps for creating a new Android Application are as follows:-

1)    Go to File à New  and click on Android Application Project.






2)    Write your application name in the Application Name.
a.     Project Name: is the name of your project directory.
b.     Package Name: is the name package namespace.
c.      Minimum Required SDK: is the lowest version of Android that your app support.
d.     Target SDK: is the highest version of Android what your app support.
e.     Compile With: is the platform version against which your app will compile.
f.       Theme specifies: the Android UI style apply for your app.
3)    Click on the next button.
4)    Leave the next screen default and click on the next button.
5)    Next screen is the launcher icon screen. You can customize also. Leave this screen as default , click on the next button.
6)    Next screen belongs to the activity template. For this project select BlankActivity and click next button.
7)    Leave the next screen default and do Finish.
                      
   Now your first android application is ready with some default files.





How to Run on the Emulator:-

            First of all before running our application on the Emulator, we need to create an Android Virtual Device (AVD).
            
1)    Click on the Android Virtual Device Manager.
    The following image shows how AVD manager look like.


2)    Click on New Button. Type AVD name. I have given Galaxy Nexus. Select Device, choose Galaxy Nexus device. We will try to run our application on Galaxy Nexus emulator.







3)    Click on the OK button.
4)    Select your AVD device and click on the start button.
5)    Click on the Launch Button.


6)    You might get some error like the following image.


7)    To fix this error, select your AVD device and click on the edit button, change the ram size to 512.
8)    Start your AVD once again. This will take some long time.
9)    Then unlock your emulator screen.
10)           Click Run Button from the toolbar. 
         This will run your first application on the Emulator.

Your application on the Emulator will look like this.






Porting of the application on an Android Device:-
1)    Plug in your device to the development machine with a USB cable.
2)    Enable USB DEBUGGING on your device.
a.     On device Android 3.2 or older,  you can find this option under Settings à Applications à Development.
b.     On Android 4.0 and newer, it’s in Settings à Developer options.
On Android 4.2 and newer versions, Developer options is hidden by default. To make it available go to Setting à About phone and tap Build number seven times.
Return to previous screen to find the Developer option.

If you are developing on Windows then you might need to install a proper USB drive for you device.
If you are connected with net windows 7 will automatically install the proper driver.
The following link helps to install driver related things.


3)    Open your first application project and click on the RUN menu and select Run Configuration.
4)    Go to Target Tab.


5)    Select Always prompt to pick device and click on the run button
6)    Then choose a running Android device.
7)    Click ok.
Then you will see some messages on console window like Uploading FirstApp.apk on device.
Installing FirstApp.apk
Success!

Check it out your android device; you will be seeing the application running.

Enjoy your First Android Application buddies. 


In the next tutorial we will learn about:-
1) Android Directory Structure.
2) AndroidManifest.xml
3) Setup the Game Architecture.


Do comments, ask questions, and don't forgot to share it with your buddies.



Game Development "Part 2"