First steps for the implementation of applications for Android devices.

This article is a practical entry point for understanding what is needed before creating an Android app: the role of Android Studio, the SDK, the emulator, the project structure and the difference between Android as an open platform and the Google services that many commercial devices include.

Related reading: iOS course structure, mobile app architecture and wireframes and frontend frameworks for mobile apps.

1. Presentation

This project is an introduction to the development of Android applications.

2. Competencies

In this project the following competencies will be worked on:
  • Ability to understand how the Android operating system works.
  • Ability to create an application for Android devices.

3. Objectives

The objectives of this article are that the student learns to:
  • Configure a development environment integrating all the necessary tools to develop Android applications.
  • Create an Android project and know the elements that compose it.
  • Create an Android Virtual Device in order to use it as an emulator and/or configure the drivers of a mobile device in order to be able to use it for tests.
  • Run an Android application on the emulator and/or real physical device.

4. Exercises

Assessment of 20%. Read the following article about Android where different myths related to this operating system are described. Answer the following questions:
  • What kind of myths does the article dismantle?

  • All those myths that criticize or try to dismantle Android's own definition as Free Software. As we can observe in Robert Ramirez Vique's document we can define Android as:

    A complete software solution for mobile devices. It includes a whole stack of applications, such as the operating system, the middleware and the key applications. It also includes tools to develop on the platform, mainly with the Java programming language. All of it under Apache free code license.

    That is, Android is free software, implemented to be used in all kinds of devices independently of their hardware unlike other operating systems such as Apple's iOS. Among the myths dismantled by the article we find:
    • Google applications are installed by default on those devices with a valid license. This practice (very common in other operating systems such as Red Hat or Microsoft) is criticized by certain articles. It is not really to help Google expand by suppressing possible competition but rather the customer who wants to obtain a device with an Official license expects to obtain those applications.
    • Google services define Android. This myth is totally false, for example in China where Google is in continuous confrontation with the Chinese government only 80 percent of the operating systems include these services.
    • Android is not open source. As we have said before, it is code under the free Apache license. Although it is true that the largest companies are the ones that receive the trial versions of the distribution first.
    • Android is not Linux. It is not true, it is based on a Linux Kernel.
    • Google charges a license fee for Google Mobile services. False, there is a fee to create "official" or, better said, certified devices.

  • Why is there discussion about whether Android is open source or not?

  • Definitely yes. Not only in the studied article but also in different sources we can read definitions such as the following:

    Totally free platform based on Linux that allows developing applications and/or modifying those already existing with Java language.

    That said, other points on which we base ourselves are the following:
    • Its core is based on the Linux kernel, in which some modifications have been carried out to adapt it to the needs of Android (devices where it is necessary to optimize their hardware to the maximum). This serves as a hardware abstraction layer to which applications have to access. In this way, if a hardware element is needed, the application will simply request the resource generically, without having to know the exact hardware model. For example, if we want to access the camera, the type, the definition or the manufacturer will not matter, we will simply access the camera by means of the corresponding driver.

    • This fact really gives us freedom to make modifications in its Kernel and complete independence from the hardware that we are using
    • Android's license is the Apache free code license. Any person who wishes can obtain the code, modify it and distribute it free of charge and without any restriction. A different thing will be if we want Google to certify our distribution as valid according to its criteria, since for that it will have to fulfill a series of requirements.
  • Do you agree with the conclusions of the article? What is your opinion?

  • To a great extent yes, I agree. In my opinion, all the information shown in the text is truthful and the myths really are false or mistaken as they correctly indicate.

    Now then, there is one myth (Google charges a license fee for Google Mobile services) that is not true but it does play a little with ambiguity. That is to say, I consider that Google has to control a little how this operating system evolves and how the new distributions evolve for each hardware platform. Its way of acting, I imagine, will be by asking for the distribution to certify and it will analyze that it fulfills some minimum security requirements.

    This fact may grant an extra cost to the device but it also avoids possible incidents. If, for example, a user looks for a more economical device, he or she can access the market of uncertified devices, which does not give us so much security but it does give us a lower cost.

    That said, it is absolutely clear that Android is free software, multi-device and modifiable.
Assessment of 25%. Install and configure Android Studio, the official and recommended IDE for the development of Android applications. The Android Studio download website is the following:

Download

The website automatically detects the operating system of the computer. One only has to press the download link. The downloaded package includes all the necessary tools to start developing applications:
  • Android Studio IDE
  • Android SDK Tools
  • Android platform tools
  • The latest version of the Android platform
  • The latest system image for the emulator
  • On what operating system have you installed Android Studio? Explain whether you have had any incident during the process.
  • Computer version
    1. Computer Version

    The problem that I have had is found in figure [2] . The solution that I have provided to the system is to update the Java version to a 64-bit version and update this environment variable.

    Problem
    2. Problem

  • New Android versions periodically appear and with them new versions of the official Android SDK. If there were a new version change, indicate how to access the window that allows updating the most recent version of the SDK.

  • In figure [3] there is a green circle where we can see the button that gives us access to the versions of the official SDK.

    Update SDK
    3. Update SDK

    Once opened, figure [4] appears to us

    SDK versions
    4. SDK Versions

  • Once the SDK Manager is open, install the Google USB driver package and Google Play Services. Attach a screenshot.

  • To install Google USB driver we have accessed the SDK Manager as in the previous section and we have activated the installation check in blue color. In figure [5] we have indicated Apply to update the sdk.

    Install Google USB driver
    5. Install Google USB driver

    Once updated we already have Google USB driver and Google Play Services installed as shown in figure [6]

    Install Google USB driver and Google Play Services
    6. Install Google USB driver and Google Play Services

  • Android Studio is also updated from time to time. Indicate what steps must be followed to obtain the latest update and where we could see what new features it includes.

  • In a red circle I have marked the way to access updates from two different ways as shown in figures [7 a] and [7 b]

    Update Android Studio

    Update Android Studio
    7 Update Android Studio

Assessment of 20%. The development process of applications follows a cycle of coding, compiling and executing in a testing environment. Android applications can be tested on a physical Android device or on an Android virtual device, Android Virtual Device (AVD). The AVDs are created and administered by means of the tool 'Android Virtual Device Manager' which can be used as a command-line tool or by means of a graphical interface from the IDE itself. When creating an AVD to simulate a specific model of Android device it is important that the virtual device be configured with a hardware specification that matches that of the physical device that one wants to simulate.
  • By means of Android Studio, create an Android virtual device. This virtual device must have the following characteristics:
    • Nexus 5 with a 4.95" screen
    • Latest available API
    • The rear camera must be that of the webcam
    • Internal storage of 400MB.
    • SD card of 500MB.
    Indicate the software and hardware characteristics that you have chosen to generate the AVD (type of device, version of the operating system, API number, memory, etc) and attach screenshots of the configurations.

    Once configured, start the emulator and explain whether there has been any incident during the process. If not, attach a screenshot of the emulator. NOTE: If the resolution of this device is too large and it is not seen well on your computer screen, choose another device with a lower resolution justifying the choice.

    The configuration of the device has been carried out in the following way:
    • Nexus 5 with a 4.95" screen

    • Nexus 5 with a 4.95 screen
      8 Nexus 5 with a 4.95" screen

    • Latest available API

    • Api
      9. API

    • The rear camera must be the webcam

    • Camera
      10. Camera

    • Internal storage of 400MB and SD card of 500MB.

    • 11 Internal storage of 400MB and SD card of 500MB

    The result obtained can be observed in figure [12]

    Motorola G
    12. Motorola G

  • (OPTIONAL) If you have a mobile device with Android operating system, configure the drivers so that Android Studio recognizes the device when it is connected to the computer. Indicate which device you have connected and explain the steps that you have followed.

  • In this case the device to emulate has been a Motorola G. The truth is that since it is a 5-inch device the result obtained on the Nexus 5 device has not varied much. The result can be observed in figure [13]

    13 Motorola G

Assessment of 35%. Once the AVD has been created and configured, the next step is to create a simple application and run it on the emulator or the mobile device. As explained in section 2.2 of the wiki, the first step to create an application is to create a project in Android Studio.

  • Create an Android project by means of Android Studio (choose the “Blank Activity” project type). Explain all the parameters selected for the creation of the project and justify the reason for your choice.

  • To carry out this task I have made a series of screenshots of the Android Studio application and in addition I will explain the reasons that have led me to the selection of these configurations. The second of the indicated data will only be used as the package of our Java classes.
    • First of all we are going to make a choice of the name of the new project. The name will be PrimeraAplicacion and the domain 1938.com.es.
    • The second point of the process is the choice of the Android version that we are going to apply. We use the wizard for the choice and the information that Android Studio shows us about each version. We are going to focus on applications for phones and tablets, in which case we will only have to select the minimum API, that is, the minimum Android version that the application will support. In this application we will focus on Android 4.0.3 as the minimum version since according to the information that Android Studio provides us, an application with this version can be executed on 94% of devices.
    • Once the version has been chosen, the next point is to select the initial activity template. In our case we choose the type Blank Activity because it is the simplest option to start a first project and it allows us to understand the minimum structure generated by the IDE without adding extra complexity from other templates.
    • With that choice, Android Studio automatically creates the basic files of the project, among them the main activity, the layout xml file, the manifest, the Gradle configuration and the package structure. The objective of this first exercise is not only to generate the project, but to understand that each one of those elements forms part of the skeleton of any Android application.

    The process is useful because it allows us to justify each of the chosen parameters. The project name identifies the application, the domain is used as the Java package, the minimum version determines the range of supported devices, and the blank activity gives us a clean base from which to continue building the example. In that sense, the exercise is not limited to pressing buttons in the wizard, but to understanding what impact each decision has on compatibility, maintainability and the future structure of the application.

    Once the project has been created, the next logical step is to run the application on the configured emulator or on the physical device. Here the student verifies that the development environment, the SDK, the emulator and the generated project all work together correctly. If the execution starts without errors, the whole installation and configuration process carried out in the previous sections is validated.

    The important idea of the complete exercise is that Android development begins much earlier than the implementation of business logic. Before creating complex screens or advanced functionalities, it is necessary to understand the platform as free software, know the official tools, update the SDK correctly, install the required packages, prepare test devices and know how the IDE generates the initial structure of a project.

    For that reason, the article combines conceptual questions with practical configuration tasks. On the one hand, it reviews the discussion about Android as open-source software and its relationship with Linux, Google services and certification. On the other hand, it shows the first real steps of a developer: installing Android Studio, solving environment problems, managing the SDK, configuring the emulator and launching the first application successfully.

The main idea of this exercise is to understand that before beginning to program, Android development requires correctly understanding the platform, the versions, the official tools, the SDK packages, the emulator configuration and the execution environment on real devices.

Bibliografía