Android Lesson 2 - Android Basics

Android has become a ubiquitous term associated with mobile devices in the past few years. “Apple or Android?” has become the main question in mobile brand affiliation, handily besting Windows and Blackberry as the dominant players in the space. But what exactly is Android and what does it mean in terms of development? This question is the premise for this first lesson in Android Development Fundamentals. The following topics in this lesson will give you a high level understanding of Android and the its development tools used for creating Android applications. While each section will be relatively short, each topic will be handled in greater detail during subsequent lessons and tutorials.

Topics Covered in This Lesson

  1. What is Android?
    1. The Android Operating System
    2. Android Tasks
    3. The Main Components of Android
    4. Google Play Services
  2. Android Development Tools
    1. The Android SDK
    2. The Android Debug Bridge (ADB)
    3. The Gradle Build System
    4. Android Studio
    5. Android Developer Tools
    6. The Android RunTime (ART)
    7. Development of Android Applications
  3. Lesson 1 Summary

Android Fundamentals Series:


Android Development Fundamentals Lesson 1 - Android Basics

What is Android?

The Android Operating System

Android is an open source (software for which the original source code is made freely available and may be redistributed and modified) operating system based on Linux. Google is the primary party heading up the Android Open Source Project (AOSP)- the group responsible for developing and maintaining Android.
Like other full-featured operating systems, Android provides users with a large user interface library, access to the file system, and 2D and 3D graphics by way of supporting the OpenGL-ES standard. Android is capable of running multiple threads at one time, allowing for the running of numerous background processes. It also comes with an embedded SQLite database.

Android Tasks

In Android a task is the term given for the use and reuse of apllication components- both relating to the user interface as we as non-user-facing and background processes. An application can access other components within Android to perform tasks. As an example of this, as a developer, you can write applications that are able to trigger other Android components, giving you access to hardware like the camera, the accelerometer, the compass and even other software like your photo gallery and internal storage. This allows you to use and manipulate items which reside outside your source code.

The Main Components of Android

Android is considered to be a full stack operating system. As a cheep and easy definition, this means that Android is able to access the underlying hardware, provides libraries, a runtime and application framework as well as offering numerous built-in user-facing applications. Consider the following flow as the basis of the Android stack:
Linux Kernel >>> Libraries and Runtime >>> Application Framework (API) >>> Applications
Linux Kernel
This is the bridge between the Android system and the underlying hardware. It is upon this kernel that all of Android is built. Instead of being written in Java (as you might suspect), the Android Linux Kernel is actually written in C. Generally, an Android app developer with work with the API and native Application when developing rather than the kernel, library and runtime.
Libraries and Runtime
This layer of the stack provides the library for a great number of common functions of the Android framework and the Java libraries for running and creating Android applications. It also houses the Dalvik RunTime; Dalvik is the runtime, bytecode, and virtual machine used by the Android system for running Android applications. As of Kit Kat (Android 4.4), developers also have the option of using the Android Runtime (ART) instead of Dalvik. As of 5.0 (Marshmallow), Android uses the ART by default.
Application Framework
This is an Application Programming Interface (API) which allows application to communicate with the Android system. This is the lowest level of the Android stack that most developers typically access.
Applications
These are the “stock” applications that come preinstalled on your device. These include apps like the camera, browser, phone, gallery, and more. These are not the crappy bloatware apps that Verizon, AT&T, Sprint and other service provider get paid to install on your device and block you from uninstalling.

Google Play Services

Android is not technically Google; however, Google has taken up so much of the charge of development and distribution of the Android operating system that is can be almost impossible to see where Google ends and Android begins. Helping blur the line of separation between the two is Google Play. Android users are familiar with Google Play as the online marketplace for downloading, buying, installing and updating apps and other media. Beyond this Google Play actually offers some very valuable services to Android developers. Through its update service, when updated app versions are uploaded, the service notifies users that an update exists and depending on user settings, can automatically trigger app updates.
Another offering than many developers find invaluable are the services and libraries offered for use within applications. Among these is the extremely popular Google Maps API, providing developers access to Google’s industry-leading map service. To learn more about the Google Play Services, check out the official documentation.

Android Development Tools

Numerous tools within the Android system make it possible to develop, build, package and deploy Android applications. Here are a handful of the main tools you will encounter in your Android coding journey.

The Android SDK

The Android Software Development Kit (SDK) is of central importance to Android development; it contains the tools required to create, compile and package applications. For the most part, developers use the Java language to develop Android applications.

The Android Debug Bridge (ADB)

One of the tools contained within the Android SDK is the ADB. Simplistically, this tool allows you to connect a virtual or physical device for device management and application debugging.

The Gradle Build System

The build system used by Android is known as Gradle. A Gradle plug-in is provided by the Android team to build applications. Configurations and dependencies are added to the build.gradle file found in the top level of the Android application. Within this file you can integrate 3rd party SDKs (like Facebook) directly into your app with minimal effort.
Here’s a sample build.gradle file from a recent project. (The details of each section will be clarified in a later lesson.)
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    signingConfigs {
        release {
            storeFile file("/Users/johnriggs/some-release-keystore.keystore")
            storePassword "some_store_password"
            keyAlias "app_release"
            keyPassword "some_key_password"
        }
    }
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.johnriggsdev.appname"
        minSdkVersion 18
        targetSdkVersion 21
        versionCode 163
        versionName "1.62.1"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "boolean", "IS_DEBUG", "false";
            debuggable false
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "boolean", "IS_DEBUG", "true";
            debuggable true
        }
    }
    productFlavors {
    }
}

android {
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v13:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
 compile 'com.google.code.gson:gson:2.3.1'
 
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.squareup.dagger:dagger-compiler:1.2.2'
    compile 'com.squareup:otto:1.3.6'
    compile 'com.jakewharton:butterknife:6.1.0'
 
 compile project(':facebook')
}

Android Studio

Android Studio is the official Integrate Development Environment (IDE) offered by Google for developing Android Applications. Users of JetBrain’s other IDEs (CLion, PyCharm, PhpStorm, WebStorm, and others) will feel right at home as Android Studio is built on top of their IntelliJ IDEA Java IDE.

Android Developer Tools

The Android Developer Tools offer editors that provide specialized ways to view and edit Android-specific files. Since XML is the base for most of Android’s configuration files, these specialized editors can allow the user to switch between a structured UI and an XML representation of the data.

The Android RunTime (ART)

Previously in the Libraries and RunTime section of the Android stack, you’ll notice that the Dalvik RunTime is the default runtime up to Android Kit Kat. As of Android 5.0, it is replaced by the Android RunTime as it boasts some significant improvements over Dalvik.
Some of these improvements include faster deployment of applications on Android devices, improved battery lfe, and a faster garbage collector in the event that an application freezes.
Here is a good link explaining the differences between the two in greater detail.

Development of Android Applications

Using Java and XML as the primary languages, developers create configuration and application logic files to build Android apps. The Android development tool translate these files into an application. When the development deploys the project, Android Studio compiles the code, packages and deploys it for use on an Android device.
During this process, the Java source files are converted to Java class files by the compiler. These class files are then converted into .dex files (Dalvik Executable). All of the requisite class files are included within this .dex file. During the creation of the .dex file, all redundant entries are eliminated, saving both space and overhead, allowing the .dex files to be smaller and more efficient than their associated class files.
Along with the .dex files, the XML, image and sound files are packaged into an .apk (Android Package) file by the Android Asset Packaging Tool (AAPT). Once the .apk is created, it contains all of the data necessary for running the Android application and can be sent to an Android device via the Android Debugger (ADB) tool.

Lesson 1 Summary

As you have seen in brief, Android is a wonderful operating system upon which to develop applications. It offers an extensive selection of development tools and support from Google Play Services. Android is ever-changing, evolving into the full-featured and powerful platform it is today. In the following lessons and tutorials, you will learn how to develop many different types of applications and begin mastering the many development tools and components of the Android system. Thank you for reading and I hope to see you in the next tutorial.

Android Fundamentals Series:


Android Development Fundamentals Lesson 1 - Android Basics

Related

Android 4948853454409992914

Posting KomentarDefault Comments

emo-but-icon

Hot in week

Comments

item
kabartobi