• Home
  • Tutorials
    • Game Development Tutorial>
      • Unit 1: Beginning Java>
        • Before you begin...
        • Day 1: Setting Up
        • Day 2: Java Basics
        • Day 3: More Basics
        • Day 4: Java Math
        • Day 5: More Math
        • Day 6: If... else...
        • Day 7: More Control Flow
        • Day 8: Looping
        • Day 9: More on Looping
        • Day 10: Inheritance, Interface
        • Day 11: Threads and Graphics
      • Unit 2: Creating a Game I>
        • Day 1: Foundations
        • Day 2: Basic Framework
        • Day 3: Taking User Input
        • Day 4: Enter the Robot
        • Day 5: Background and Sprites
        • Day 6: Adding Enemies
        • Day 7: Shooting Bullets
        • Day 8: Animations
        • Day 9: 2D-Arrays
        • Day 10: Painting the Tilemap
      • Unit 3: Creating a Game II>
        • Day 1: Level Creation - Part 1
        • Day 2: Level Creation - Part 2
        • Day 3: Level Creation - Part 3
        • Collision Detection Basics
        • Day 4: Collision Detection Part 1
        • Day 5: Collision Detection Part 2
        • Day 6: Collision Detection Part 3
        • Day 7: Health System & Death
        • Day 8: Basic AI & Final Touches
      • Unit 4: Android Game Development>
        • Day 1: Introduction to Android
        • Day 2: Setting up for Development
        • Day 3: Creating our First Android Application
        • Day 4: Parts of an Android Application
        • Day 5: The Android Game Framework: Part I
        • Day 6: The Android Game Framework: Part II
        • Create an Android Game From Scratch (or port your existing game)
        • Day 7: Creating an Android Game (From Start to Finish)
      • Reference Sheet
    • Zombie Bird Tutorial (Flappy Bird Remake)>
      • Unit 1: Building the Game>
        • Introduction
        • Day 1: Flappy Bird - An In-depth Analysis
        • Day 2: Setting up libGDX
        • Day 3: Understanding the libGDX Framework
        • Day 4: GameWorld and GameRenderer and the Orthographic Camera
        • Day 5: The Flight of the Dead - Adding the Bird
        • Day 6: Adding Graphics - Welcome to the Necropolis
        • Day 7: The Grass, the Bird and the Skull Pipe
        • Day 8: Collision Detection and Sound Effects
        • Day 9: Finishing Gameplay and Basic UI
        • Day 10: GameStates and High Score
        • Day 11: Supporting iOS/Android + SplashScreen, Menus and Tweening
        • Day 12: Completed UI & Source Code
    • Android Application Development Tutorial>
      • Unit 1: Writing Basic Android Apps>
        • Before you begin...
        • Day 1: Android 101
        • Day 2: Getting to Know the Android Project
        • Day 3: The Development Machine
        • Day 4: Building a Music App - Part 1: Building Blocks
        • Day 5: Building a Music App - Part 2: Intents
        • Day 6: Building a Music App - Part 3: Activity Lifecycles
  • New Forum
  • About Us
    • Contact Us
  • Our Games
    • TUMBL: FallDown
  • Facebook
  • Twitter

      GAME DEVELOPMENT TUTORIAL: DAY 4-4: Parts of an Android Application

Welcome to Day 4 of Unit 4: Android Game Development. 

We will pick up where we left off in Day 3. By now, you should have successfully created and ran your first Android project. 
In today's lesson, we will discuss how you can use a real device for testing, and then we will discuss the important parts of an Android application.

No coding is necessary for this lesson (that's coming in the next lesson) so no need to get Eclipse started up (unless of course, you would like to follow along)!
Picture

Running Applications on a Real Device

If you have tried your hand with the emulator, you have probably noticed that it is not exactly a speed demon. When you want to test your game for responsiveness, it is not a great idea to use an emulator.

So you will probably be relying on a real device for testing. I personally use a Galaxy Nexus when I develop, and do compatibility checks with an old Galaxy S.

How does one use a real device with the Android SDK? Follow the steps below:

1. Enable USB Debugging

On your Android device, open up Settings. The location of the USB Debugging settings can vary. Here are some possible locations:

1. On earlier versions of Android, you could find it by selecting Applications and then Development. 
Check that USB Debugging is enabled.

2. On other versions of Android, there will be a Developer options button below System settings, which will have a USB debugging option:

Note: (On the latest versions, Google made a change that requires you to open up "About phone" and tap your "Build number" 7 times to get the "Developer options" to show up. This change was made to prevent non-developers from accidentally accessing complex settings.
Picture
Picture

2. Connect the device to the computer

Once you have enabled USB debugging, you should now connect your device to the computer. Now, open up your new Eclipse (or old version if you decided to use that) and run an application! 

You should be able to see this screen (if not, click on the drop down arrow to the right of the Run button, click Run configurations, click on the Target Tab, and select the Radio button labeled Always prompt to pick device. Then try running again.).
Picture
You can see that I am given the option of Choos(ing) a running Android device and Launch(ing) a new Android Virtual Device.

If I choose the former, the Application will deploy to my device (and this is reflected in the console as shown below).
Picture
And sure enough, when I turn on my phone, the application will be running!

Examining the Android Application

Before we begin creating our game on Android, we must first discuss the various parts that come together to form an Android application. I will be providing multiple screenshots and describing what each section does. The information will not go into too much detail, as most of this information is learned by doing, not reading.

Project Folders

Picture
Our app directory

The parts of an Android APp

src folder - just like in a Java project, this is where the code goes.


gen folder - this folder contains automatically generated code. You do not want to manually edit it. Inside it, the R.java file assigns a numerical value to each resource that you place into your project. It will work flawlessly (for the most part) without your involvement.


Android 4.2, Android Dependencies, libs contain various libraries and dependencies required by the application.


assets folder will contain various resources. The res folder can also contain resource such as strings, layouts, and images Usually, the res folder contains various versions of each of these resources so that your Android application will use different strings, layouts, and images depending on the language, screen size, and screen resolution, respectively.


proguard refers to a tool that "shrinks, optimizes, and obfuscates" your code to make it harder to reverse engineer. It works automatically and will prevent MOST users from retrieving your full source code.

Android manifest (AndroidManifest.xml)

The AndroidManifest.xml file is a very important one that contains a lot of information. In here, you can change the version number of your game, minimum SDK version, the MAIN activity (similar to a main method, the first activity, or page, that opens), and much more. We will be talking about this file in more depth throughout the tutorial.

If you double click on the AndroidManifest, you will see the following:
Picture
The first four tabs make it very easy to change features. By filling out a few forms and pressing buttons, you can add permissions (described below), change version numbers (for patches), and etc. When you interact with the first four tabs, you are making changes to the AndroidManifest.xml file.

You can see the XML version of this file by selecting the tab labeled: AndroidManifest.xml.
Picture
Here, you can see various information regarding your app all in one place.

permissions

An interesting feature on Android is that, by default, it prevents any application from making unwanted changes to the device. As such, it implements a system of Permissions. Every time that a user installs an App, Android will inform the user that the Application will require certain permissions (such as the ability to access your SD card, camera, or GPS). If the user denies these permissions, the application will not install.

These permissions, although most people ignore them completely, are very powerful. Potentially, you could lose all the files from your SD Card (if the creator of an Application were to add a few lines of code to their App), and have your address and information tracked.

Therefore, to maximize the number of downloads by earning the confidence of wary users, you should only ask for permissions that you absolutely need (such as wakelock, which prevents the phone from going to sleep). By doing this, you prevent yourself from making accidental changes to the user's device.

That's all you will need to know for now regarding Android. 
In Day 5, we will begin creating our framework, so that we can build our game on top of it.

Thank you so much for reading!
As always, feel free to email me questions at jamescho7@kilobolt.com

Picture
No source code is available for this lesson.
Go to Unit 4: Day 3
Go to Unit 4: Day 5
comments powered by Disqus
© 2014 Kilobolt, LLC. All rights reserved.