What is Android? Some stats what the mobile world looks like.
Prepare for development. IDE setup & review, emulator vs real device.
How does an Android app look like? Packages, common components & platform tools
Deeper look into components - devs burden (libs), Services, Receivers, Content Providers
How to test Android apps? Unit & Instrumented tests. Appium vs Robotium vs Selendroid
Best practices - Kotlin, RxJava, Dagger, MVP/MVVM/MVI/Clean architectures
Material design everything - a cool design theory introduced by Google
Linux Kernel
Display Driver
Camera Driver
WiFi Driver
Binder Driver
C++ Libraries & Android Runtime
OpenGL
SSL
WebKit
SQLite
Application Framework
Activity Manager
Window Manager
View System
Package Manager
Location Manager
Resource Manager
Android Wear
Android Auto
Android TV
Android Things
- 2 billion monthly active devices (2017)
- 3 500 000 apps
- 1.3 billion monthly active devices (2018)
- 2 200 000 apps
2008
2015
2009
2012
Version codes
2.2 -2.3
5.0
7.0
6.0
4.0
4.4
API level
Latest is Android O released in 2017 - 8.0 (API 26-27). What does O mean?
9-10
21-22
24-25
- API level - mostly used in development
- Version codes - used in public especially on update/upgrade
Data collected during a 7-day period ending on February 5, 2018.
- Rich layout editor
- Android-specific refactoring & quick fixes
- Supports Android wear
- Many more features
Includes:
NO
RIP ADT
+ Mock location
+ Emulate performance
+ Mock network connection
+ Easily intercept network traffic using Charles
+ Fast deploy
+ Access apps internal folders that are usually hidden without root
- Eats at least 1 GB RAM
- Hard to test gestures
+ Test custom implementations like Samsung has
+ Doesn't eat RAM
+ Testing using gestures
+ Easy to replicate bugs that users already have
+ Allows push notifications test
- Slower deploy
- No access to other internal device folders unless rooted
- Thousands of different devices
- Expensive to buy phones
User: Gmail (ID 1)
User: Messenger (ID 2)
Process: gmail
Virtual Machine 1
Virtual Machine 2
Process: messenger
Multi-user Linux system
Java
XML
class AppsActivity extends Activity {
void onCreate() {
setContentView(XML);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
+
What happens to the XML setContentView is called?
Where are all view ids stored?
Where are instrumented tests placed?
Unique package name:
- com.google.android.gm - Gmail
- com.facebook.katana - Facebook
- com.instagram.android - Instagram
* visible in browser when app is selected in Google Play
Target API:
- OS version you are targeting from API level 14 - 27
- Phone & Tablet, Wear, TV, Auto or Things
Surest way to fix common errors
Click on the hyperlink and follow the installation process
ViewGroup
View
Unique ID
Instrumented tests
Unit tests
Images
XML for UI
Custom fonts
strings, colors, themes
public final class R {
public static final class anim {
public static final int abc_fade_in=0x7f010000;
}
public static final class color {
public static final int black=0x7f06002a;
}
public static final class id {
public static final int tab_circle_view=0x7f0a06c5;
}
public static final class layout {
public static final int event_logs_seconds=0x7f11032c;
}
}
<com.example.mypackage>.R
with all resource ids - strings, layout, images
Widgets
Layout
Text
Date
Images
Custom Views
Intent i = new Intent(FirstActivity.this, SecondActivity.class);
i.putExtra("KEY", "VALUE");
FirstActivity.this.startActivity(i);
Call other apps to:
Let's try it!
The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
What components the app has (like activities)?
What permissions are required from the user?
Which is the first activity that should be started?
Which is the icon displayed in the launcher?
Which is the style of the elements used throughout the app?
Does the app support right to left languages?
Based on:
Works with dependencies from:
Flexibility at its finest:
Convert Java classes to bytecode
1)
2)
Convert Oracle JVM bytecode to Dalvik
3)
Combine Dalvik bytecode & resources into APK
APK = Android Package Kit
Instant Run
APK install process
Event types
Component that can do long-running operations in the background, and does not provide a user interface
Find contacts containing "anna"
Content Provider
SQLite
* scary things inside
Accessibility
Fragments
android.support.design
(Material Design)
Drawer
CardView
Unit Tests
Instrumentation Tests
Cross-app functional UI testing
70
20
10
What folders Android has for unit / instrumentation (integration) tests?
Mocks the Android environment as it uses too many static methods.
- does things inflating Views
- simulates different device conditions
- shadows - ways to test hardware dependencies
Mock all kinds of objects including static methods
- Waits for async jobs to finish
- Multiprocess testing
- Test WebViews
- Easily test lists
* Orchestator runs each test in a single instrumentation invocation
* If one test fails, it won't crash the app
<android-sdk>/tools/uiautomatorviewer
Performs interactions on user apps and system apps
mInstr = getInstrumentation()
mDevice = UiDevice.getInstance(mInstr);
mDevice.pressHome();
mLauncher = new UiSelector()
.description("Apps");
allAppsButton = mDevice.findObject(mLauncher);
// Perform a click on the button to load the launcher.
allAppsButton
.clickAndWaitForNewWindow();
Last updated: 3 days ago
Last updated: a year ago
Last updated: beginning of 2018
- Uses UiAutomator / UiAutomator2 for API Level >= 17
- Uses Selendroid for API Level < 17
class MyKotlinClass {
val name = "Georgi"
val surname = "Mirchev"
}
class MyJavaClass {
public String getName() {
return "Georgi";
}
public String getSurname() {
return "Mirchev";
}
}
println(bob?.department?.head?.name)
if (bob!= null && bob.department != null
&& bob.department.head != ull) {
// Same
}
class Person(val name: String,
var age: Int) {
// val - immutable
// var - mutable
}
class Person() {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
// Getter + Setter for age
}
Dependency Injection
Observer Pattern
App Component
- GSON parser
- ErrorHandler
User Component
- User provideCurrentUser()
Activity Component
- provideApiService(GsonParser, ErrorHandler, User)
MVP
MVVM
MVI
Developed by Google and introduced in 2014