Sample Android App Development - Apps: Beginner's Guide For App Programming, App Development, App Design (2015)

Apps: Beginner's Guide For App Programming, App Development, App Design (2015)

Chapter 4. Sample Android App Development

It's time to get your hand on simple app development. This section will give you a run down of the procedures involved in creating your first Android app project.

Prepare the Environment

The environment refers to the app development platform to be used. It will process codes and generate preview of the outcome. The first step is to download Android Studio and the latest SDK tools via SDK Manager.

Android Studio is the app development platform offered by Android developers. It runs using intelligent code editor capable of analyzing codes, refactoring and other advance coding techniques.

Before downloading Android Studio, be sure the platform is compatible with your system. Minimum system requirements are the following for three main operating systems.

System Components




Operating System

Vista/7/8, 32 or 64-bit

OS X 10.8.5 or later, up to 10.9

GNOME or KDE Desktop

Hard Disk Space

400 MB

400 MB

400 MB

Minimum RAM (Recommended RAM)

2 GB (4 GB)

2 GB (4 GB)

2 GB (4 GB)

Minimum Space for Android SDK and emulators

1 GB

1 GB

1 GB

Minimum Screen Resolution

1280 x 800

1280 x 800

1280 x 800

Development Kits

Java Development Kit (JD) 7

Java Development Kit (JD) 7

Java Development Kit (JD) 7

Other Platforms

Java Runtime Environment (JRE) 6

GNU C Library (glibc) 2.15 or higher

The SDK Manager is a system that separates SDK tools, platforms and other vital programming solutions into packages. It's advisable to get the latest SDK tools, which shouldn't be a problem as the SDK Manager installs the latest tool versions by default. The manager is installed together with Android Studio and can be launched by going to Tools menu then look for Android. The SDK Manager should be available under the Android tool set.

Start creating your app project after installing Android Studio.

Creating an App Interface

Launch Android Studio and you will be greeted with a Welcome screen. Look for New Project and it will direct you to the next dialog box where you can configure project details. It will ask you for four main details—the App Name, Company Domain, Package name, and Project location. App Name is basically the name you want to give an app. Details doesn't have to be formal.

Company domain is your company's website or domain name. This will append to new app developed, which will be helpful for app marketing. For now, you can type any domain for practice. Edit this field later once you're ready to build an app for sale.

Filling out the company domain will also fill out the package name. Edit this part later by clicking the Edit link.

Project location is the folder where the app project files will be stored. Complete all these details and hit Next.

The next page will limit the minimum Android OS version where the app will run. For Minimum SDK, choose API 8: Android 2.2 (Froyo). This means that Froyo is the earliest app version compatible with your app. You can choose other preferred minimum SDK option. Leave all the entries without changing then hit Next.

Look for Add an activity to <template>. Choose Blank Activity then hit Next. Activity refers to the unique Android feature that allows access to the program. A basic and main activity for user is launching the app. However, developers can further enhance the app by adding other activities.

After setting the activity, configure other options needed for running the app. Look for Choose options for your new file. Under this option, configure Activity Name and edit it to MyActivity. Change Layout name and Title to activity_my and MyActivity, respectively. The Menu Resource Name will have menu_my as its value. Hit Finish to complete the project. Completing this project results to a simple “Hello World” app that come complete with basic default files.

Several vital codes must be kept in mind as fundamental codes that introduce you to app development. See the following codes and their functions.


This XML code represents the activity you set with your project. It generates a simple user interface preview with text view showing the text “Hello World!”


Gradle is a file used for compiling and building the mobile app project. Each project module comes with its own build.gradle file, as well as a universal build.gradle file for the completed project. A developer usually concentrates on app module build.gradle file. Other dependencies are configured together with build.gradle file like compiledSdkVersion, minSdkVersion, targetSdkversion, and a lot more, which you'll learn in advanced app programming.


Take note that some details on the code are the ones filled out at the beginning of app development. This code is responsible for running the Activity class code, which will load its corresponding activity and show the layout file containing “Hello World!”

Running the App

Now that your simple app is ready to go, it's time to test it out by running it on multiple platforms. You can run the app through the actual device or through an emulator. Running the app on both platforms require Android Studio for installation and loading. Command line can also be used to load the newly developed app.

Testing on Actual Portable Device Using Android Studio

In testing the app on a real device, you need to install the app first using a different method than the traditional way of installing apps from Google Play. Set up the device plugging it in your development machine (or computer) using its USB cable. You may need to install necessary drivers to detect the device. Refer to your device's manual to follow driver installation procedures if it's your first time to do so.

Once plugged in, activate USB debugging feature on the portable device. This feature can be found in different locations depending on the device's OS version. Devices with earlier Android OS up to Android 3.2 has this option under Settings> Applications> Development. Newer devices starting from Android 4.0 has the option under Settings> Development options.

Load Android Studio then look for your project's file. Hit Run, a command found on the toolbar area. It will let you choose a device for operating the app. From Choose Device, tick Choose a running device option, then OK. It will then install the app then load accordingly.

Test on Portable Device Using Command Line

Running the app via command line requires manual coding. Open the usual command line and look for project directory files, which was set right at the beginning of app development. Using Gradle file, this procedure will create the app's .apk file, or the file similar to compressed file that can be transferred to portable devices and installed manually.

After navigating to the project folder, type gradlew.bat assembleDebug for Windows platforms or $ chmod +x gradlew and $ ./gradlew assembleDebug for Mac and Linux systems. Take note that the commands for Mac and Linux should be separated into two lines, with both line starting with the dollar sign. Doing this command will then build the .apk file.

From there, you should begin running the app on the command line with the command adb install app/build/outputs/MyFirstApp-debug.apk. It will install the app on the device, which you will search for manually. The app is named MyFirstApp. Open it and it should run on your device.

Testing on Emulator with Android Studio

Aside from running the sample app on the actual device, it's also possible to run the app using an emulator. An emulator is a platform that mimics your target device's environment. It has settings similar to the target device, giving you a complete picture of how the app should look like once it's loaded on the actual device.

Just like in running the app on an actual device, you will also need Android Studio or command line to operate the app on top of an actual emulator.

Create an Android Virtual Device (AVD) by going to Android Studio>Tools >Android >AVD Manager. Look for AVD Manager icon to list all available emulator environment. Details found on the emulator includes Phone models, profiles, screen resolution, and target Android OS. Don't be surprised to see phone models listed on the emulator. When one of these profiles are selected, the emulator will load the same environment that the specific model has for accurate app testing.

On the AVD Manager, look for Create Virtual Device then select for preferred device configuration. Click Next. Select system version to load then load Next. Check configuration settings and verify. Hit Finish to complete setup.

Follow the same procedures for running Android Studio. But instead of selecting Choose a running device, choose Launch Emulator. Click the Android virtual device and click the drop-down menu to look for preferred emulator configuration. Click OK.

Wait for the emulator to load. Once loaded, it may ask you to unlock the screen like in an actual device. Unlock and wait for the app to load on the screen.

Testing App on Emulator Using Command Line

Follow the same procedures for coding and running app on actual device to build its .apk file. Open emulator and look for MyFirstApp. Open and wait for the app to load.

This app is quite simple, but it's a good start in knowing the fundamentals of app development. In time, you can use Android Studio to create a better looking user interface for your app.