android overview
DESCRIPTION
Introduction to Android programming.TRANSCRIPT
Android Overview
Jussi Pohjolainen
What is Android?
• Android is a free open source mobile opera<ng system using modified version of the Linux Kernel – Google apps are not open source (Market, Gmail, Maps)
• Offers full stack: OS, middleware, apps, sdk.. • Developers write apps using Java language and Google Java libraries – OS, middleware, key mobile apps
PlaMorm Versions (Feb 24th, 2015)
Architecture
WriUen in Java
APIs for programmers
UI elements Access data from another apps Access to non-‐
code resources
Lifecycle of Apps
Display alerts
C Libraries
Core libraries and VM
Kernel
Linux Kernel on Android
• Has standard Linux kernel with kernel enhancements to support Android
• No standard GNU C (glibc) Library support – Uses custom libc (bionic libc) because of performance and licensing issues
• No na<ve windowing system • Does not include full set of standard Linux u<li<es
• To access shell, use adb shell command
Dalvik VM • Dalvik VM is a so]ware that runs the apps on android devices – Dalvik can be found on phones, tablets, TVs
• Not Java VM! – Designed for slow CPUs and liUle RAM
• Programs are wriUen with Java, compiled to bytecode and then converted to Dalvik executable files (.dex) – .java -‐> .class -‐> .dex
• The .dex files and resources are zipped into android packages (.apk) – *.dex -‐> myapp.apk
Distribu<on
• You have several op<ons for distribu<on – .apk files can be installed via memory card, web sites, e-‐mail
– App stores • Several stores available – Google Play Store – Amazon App Store – GetJar App Store – Samsung Apps – ( Nokia Store )
Google Play (Android Market)
• Google Play is an online so]ware store developed by Google – Music, Books, Magazines, Movies and Apps
• Preinstalled on some Android devices • To publish, developer must pay ~16€ (Visa, Visa Electron)
• Developer gets 70% of the app price • No human verifica<on; apps are uploaded to store immediately!
ANDROID TOOLS
Tools
• SDK Tools (Google) – Standalone command line tools for building android apps
• IDE – Android Studio (Google) • This will install also SDK Tools on startup
– Eclipse (requires plugin) – IntelliJ Idea
SDK tools
• SDK tools are all you need • Contains all necessary command line tools for building and running your apps
• When SDK tools are downloaded and installed, you must – Install Android PlaMorm – Configure emulator
SDK Tools
Command Line Tools: tools/
Command Line Tools: platform-tools/
Install PlaMorms
• To install plaMorms (2.2, … 4.4), open SDK Manager
• How? – android sdk
• Select the plaMorms you like to install
plaMorms/
Create and Configure Emulators
• To create and configure emulators (android virtual devices) – android avd
• Click "New…" to create new virtual device
Virtual Device is SLOW…. • Don't use virtual device, use
real device • Use HAXM! • Buy SSD • [x] Snapshot saves a snapshot
of emulators RAM (hibernate) – Speeds up boo<ng
• [x] Use Host GPU uses host computer's graphics card – Speeds up all graphics
opera<ons • You cannot have both of these
on at the same <me!
HAXM?
• Download HAXM using SDK Manager
• Install it • Configure your editor to use INTEL cpu
• When launching the emulator you should see something like HAX is working
Genymo<on
• Fast third-‐party emulator to run and test your apps
• 20 pre-‐configured devices • Resizable windows • Sensor emula<on, mul<-‐touch, camera, etc. • Free for personal use
Android Studio
• Installs SDK Tools – Mac: /Users/<user>/Library/Android/sdk – Win: /Users/<user>/sdk
• Features – GitHub integra<on – Build apps for phones, TV, Google Glass – BeUer virtual device manager – Layout editor – Built on top of IntelliJ IDEA
CREATING ANDROID APP COMMAND LINE
Android SDK Essen<al Tools • android
– To create/update Android projects and modify Android Virtual Devices
• Android Emulator – To run your app
• adb (Android Debug Bridge) – Interface between emulator or device. Install apps, shell the device, issue commands
• Other needed tools – Ant
• To compile and build your apps – Keytool and Jarsigner
• To sign your .apk package
Crea<ng Project: Targets
Crea<ng Project
Result
Building
• Install Ant – http://ant.apache.org/bindownload.cgi
• For debug: – ant debug
• For release – ant release
• Release version must signed using keytool and jarsigner
Building
Result
Android Virtual Devices
• To run the emulator, you must configure android virtual device
• To open AVD, use command android avd • Click new to create new AVD
Star<ng the Emulator
• In avd, click start Or • use emulator –avd youravd command in command line
Installing App • The compiled and packaged applica<on can be found in the bin/ directory
• In debug – mode, the app cannot be distributed in Google Play, but it can be installed on device or emulator
• To see list of devices aUached to your computer (devices, emulators), use command – adb devices
• adb? = Android Debug Bridge, command line tool for communica<ng between devices and emulators
Installing
• You need to use the adb app to install the app • If you have only one device aUached, the following command is enough: – adb install HelloWorld-debug.apk
• If you have several devices aUached, then you must specify the target – adb –s emulator-5554 install HelloWorld-debug.apk