CS436 - Mobile Application Development: Dr. Usman Khan Durrani

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

CS436 - Mobile

Application
Development
DR. USMAN KHAN DURRANI
PHD. RMIT UNIVERSITY – MELBOURNE AUSTRALIA

MASTERS OF IT – RMIT UNIVERSITY – MELBOURNE AUSTRALIA


Week 2a: Exploring
the Android Studio
IDE
Meet Android Studio – Arctic
Fox
Based on IntelliJ IDEA . Android Studio [Android Studio Arctic Fox | 2020.3.1 Patch 3
(October 2021)] offers even more features that enhance your productivity when building
Android apps, such as:

• A flexible Gradle-based build system


• A fast and feature-rich emulator
• A unified environment where you can develop for all Android devices
• Apply Changes to push code and resource changes to your running app without
restarting your app
• Code templates and GitHub integration to help you build common app features and
import sample code
• Extensive testing tools and frameworks
• Lint tools to catch performance, usability, version compatibility, and other problems
• C++ and NDK support
• Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud
Messaging and App Engine

3
Project Structure in AS
Each project in Android Studio contains one
or more modules with source code files and
resource files.

Types of modules include:


• Android app modules
• Library modules
• Google App Engine modules

4
Project Structure in AS
All the build files are visible at the
top level under Gradle Scripts and
each app module contains the
following folders:
1. manifests: Contains
the AndroidManifest.xml file.
2. java: Contains the Java source code
files, including JUnit test code.
3. res: Contains all non-code
resources, such as XML layouts, UI
strings, and bitmap images.

5
AS User Interface

6
Tutorial 0 Example

7
Developer workflow basics
To efficiently build a well-designed app for
Android, you need some specialized tools:

1. Set up your workspace - This is


the phase you probably already
finished: Install Android Studio
 and create a project.

8
Developer workflow basics
 continued

2. Write your app - Now you can get to


work. Android Studio includes a variety of
tools and intelligence to help you work
faster, write quality code, design a UI, and
create resources for different device
types.

9
Developer workflow basics
 continued

3. Build and run - During this phase, you build your


project into a debuggable APK package that you
can install and run on the emulator or an Android-
powered device.

4. Debug, profile, and test - This is the iterative phase in


which you continue writing your app but with a focus on
eliminating bugs and optimizing app performance. Of
course, creating tests will help you in those endeavors.

10
Developer workflow basics
 continued

5. Publish - When you're ready to


release your app to users, there are
just a few more things to consider,
such as versioning your app,
building an Android App Bundle, and
signing it with a key. 

11
Projects overview
Project

Module 1 Module 2 Module 3


A project in Android Studio contains everything
that defines your workspace for an app, from
source code and assets, to test code and build
configurations.

12
Project

Projects overview Module 1 Module 2 Module 3

a. A module is a collection of source files


and build settings that allow you to divide
your project into discrete units of
functionality.
b. Project can have one or many modules
and one module may use another module
as a dependency.
c. Each module can be independently built,
tested, and debugged.
13
Project

Module overview Module 1 Module 2 Module 3

a. Android app module:


1. Phone & Tablet Module
2. Wear OS Module
3. Android TV Module
4. Glass Module

14
Project

Module overview Module 1 Module 2 Module 3

b. Library module: Provides a container


for your reusable code, which you can
use as a dependency in other app
modules or import into other projects.

1. Android Library
2. Java Library

15
Project

Module overview Module 1 Module 2 Module 3

c. Google Cloud module: Provides a


container for your Google Cloud
backend code. This module has the
required code and dependencies for a
Java App Engine backend that uses
simple HTTP, Cloud Endpoints, and
Cloud Messaging to connect to your
app

16
Week 2b: Build
and run
application
Build and run your app
Android Studio sets up new projects to deploy
to the Android Emulator or a connected device
with just a few clicks.

Once your app is installed, you can use 


Apply Changes to deploy certain code and
resource changes without building a new APK.

18
Run apps on the Android
Emulator
The Android Emulator simulates Android devices on
your computer so that you can test your application on
a variety of devices and Android API levels without
needing to have each physical device.

The emulator provides almost all of the capabilities of


a real Android device. You can simulate incoming
phone calls and text messages, specify the location of
the device, simulate different network speeds, simulate
rotation and other hardware sensors, access the
Google Play Store, and much more.

19
Run apps on the Android
Emulator
The Android Emulator has additional
requirements beyond the basic system
requirements for Android Studio, which are
described below:
SDK Tools 26.1.1 or higher
64-bit processor
Windows: CPU with UG (unrestricted guest) support
HAXM 6.2.1 or later (HAXM 7.2.0 or later recommended)

20
Run apps on a hardware
device
When building an Android app, it's
important that you always test your
app on a real device before releasing it
to users.
1. Set up a device for development
2.  Install OEM USB drivers
3. Connect to your device using USB
4. Get the Google USB Driver

21
Week 2c:
Configure your
build
Configure your build
1. The Android build system compiles app resources and
source code, and packages them into APKs or Android App
Bundles that you can test, deploy, sign, and distribute.

2. Android Studio uses Gradle, an advanced build toolkit, to


automate and manage the build process, while allowing
you to define flexible custom build configurations.

3. Each build configuration can define its own set of code and
resources, while reusing the parts common to all versions
of your app.

23
Configure your build -
Continued
4. Gradle and the Android plugin run independent of
Android Studio.
5. This means that you can build your Android apps
from within Android Studio, the command line on
your machine, or on machines where Android Studio
is not installed (such as continuous integration
servers).

24
The build process

25
Debug your app
Android Studio provides a debugger that
allows you to do the following and more:

Select a device to debug your app on.


Set breakpoints in your Java, Kotlin, and
C/C++ code.
Examine variables and evaluate expressions
at runtime.

26
Debug your app

DEBUG

27
Week 2c: Testing
Android application
Testing Android application
1. Android Studio is designed to make testing
simple.
2. With just a few clicks, you can set up a JUnit test
that runs on the local JVM or an instrumented
test that runs on a device.
3. We can also extend your test capabilities by
integrating test frameworks such as Mockito to
test Android API calls in your local unit tests, and 
Espresso or UI Automator to exercise user
interaction in your instrumented tests. 

29
Types of Tests in Android
Local tests: Unit tests that run on your local machine
only. These tests are compiled to run locally on the
Java Virtual Machine (JVM) to minimize execution
time
Instrumented tests: Unit tests that run on an Android
device or emulator. These tests have access to
instrumentation information, such as the Context for
the app under test
UI tests: This type of test verifies that the target app
behaves as expected when a user performs a specific
action or enters a specific input in its activities.

30
Week 2d: Profiling
Android application
Profile app performance
1. An app is considered to have poor performance if it
responds slowly, shows choppy animations, freezes, or
consumes too much power.

2. Fixing performance problems involves identifying areas


in which your app makes inefficient use of resources
such as the CPU, memory, graphics, network, and the
device battery. 

3. To find and fix these problems, use the profiling and


benchmarking tools and techniques described in this
topic.
32
Profile app performance
Android Studio offers several profiling tools
to help find and visualize potential problems:
1. CPU profiler: This tool helps track down
runtime performance issues.
2. Memory profiler: This tool helps track memory
allocations.
3. Network profiler: This tool monitors network
traffic usage.
4. Energy profiler: This tool tracks energy usage,
which can contribute to battery drain.

33
Week 2e:
Publishing Android
application
Publish your app
Publishing is the general process that makes your Android
applications available to users. When you publish an
Android application you perform two main tasks:

• You prepare the application for release. During the


preparation step you build a release version of your
application, which users can download and install on their
Android-powered devices.

• You release the application to users. During the release step


you publicize, sell, and distribute the release version of your
application to users.

35
Preparing your app for
release
1. Configuring your application for release
2. Building and signing a release version of
your application
3. Testing the release version of your
application
4. Updating application resources for release
5. Preparing remote servers and services that
your application depends on

36
Releasing your app to users
You can release your Android
applications several ways.
1. Release applications through an
application marketplace such as Google
Play
2. Release applications on your own
website
3. Sending an application directly to a user

37
Questions
EMAIL:
[email protected]
K
38

You might also like