android overview

37
Android Overview Jussi Pohjolainen

Upload: jussi-pohjolainen

Post on 06-May-2015

1.591 views

Category:

Technology


1 download

DESCRIPTION

Introduction to Android programming.

TRANSCRIPT

Page 1: Android Overview

Android  Overview  

Jussi  Pohjolainen  

Page 2: Android Overview

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  

Page 3: Android Overview

PlaMorm  Versions  (Feb  24th,  2015)  

Page 4: Android Overview

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  

Page 5: Android Overview

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  

Page 6: Android Overview

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  

 

Page 7: Android Overview

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  )  

Page 8: Android Overview

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!  

Page 9: Android Overview

ANDROID  TOOLS  

Page 10: Android Overview

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  

Page 11: Android Overview

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  

Page 12: Android Overview

SDK  Tools  

Page 13: Android Overview

Command  Line  Tools:  tools/

Page 14: Android Overview

Command  Line  Tools:  platform-tools/

Page 15: Android Overview

Install  PlaMorms  

•  To  install  plaMorms  (2.2,  …  4.4),  open  SDK  Manager  

•  How?  –  android sdk

•  Select  the  plaMorms  you  like  to  install

Page 16: Android Overview

plaMorms/  

Page 17: Android Overview

Create  and  Configure  Emulators  

•  To  create  and  configure  emulators  (android  virtual  devices)  –  android avd

•  Click  "New…"  to  create  new  virtual  device

Page 18: Android Overview

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!  

Page 19: Android Overview

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  

Page 20: Android Overview

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    

Page 21: Android Overview

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  

Page 22: Android Overview

CREATING  ANDROID  APP  COMMAND  LINE  

Page 23: Android Overview

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  

Page 24: Android Overview

Crea<ng  Project:  Targets  

Page 25: Android Overview

Crea<ng  Project  

Page 26: Android Overview

Result  

Page 27: Android Overview

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  

Page 28: Android Overview

Building  

Page 29: Android Overview

Result  

Page 30: Android Overview

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  

Page 31: Android Overview
Page 32: Android Overview

Star<ng  the  Emulator  

•  In  avd,  click  start  Or    •  use  emulator –avd youravd  command  in  command  line  

Page 33: Android Overview

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  

Page 34: Android Overview
Page 35: Android Overview

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

 

Page 36: Android Overview
Page 37: Android Overview