LAP2 iOS and Android Development environment setup

25
Laboratorio Avanzato di Programmazione II Lesson 1: Native Platforms Development environment setup Prof. Antonio S. Calanducci Corso di Laurea in Informatica, Unict 27 Apr 2016

Transcript of LAP2 iOS and Android Development environment setup

Page 1: LAP2 iOS and Android Development environment setup

Laboratorio Avanzato di Programmazione II

Lesson 1: Native Platforms Development environment

setup

Prof. Antonio S. Calanducci Corso di Laurea in Informatica, Unict

27 Apr 2016

Page 2: LAP2 iOS and Android Development environment setup

OutlineOverview of the mobile platforms: iOS / Android

• ecosystem, devices, languages, tools, revenue models

Lab 1: “Hello World” for iOS

• installation and configuration of an iOS dev env

• deploy to iOS Simulator and devices

Lab 2: “Hello World for Android”

installation and configuration of an Android dev env

• deploy to Android Emulator and devices

Page 3: LAP2 iOS and Android Development environment setup

Apple ecosystemProduction and sale of hardware:

• Smartphones (iPhone) and Tablet (iPad)

• Music players (iPod)

• PC/ e laptop (iMac and MacBook)

• Wearable (Apple Watch)

• Entertainment (Apple TV)

• Automotive ? (Apple Car?)

Page 4: LAP2 iOS and Android Development environment setup

Apple ecosystemDesign and development of OSes:

• Smartphones/iPod touch and Tablet (iOS)

• Music players (proprietary OS)

• PC/ e laptop (OS X - Mac OS in the past)

• Apple Watch (WatchOS)

• Apple TV (tvOS)

• Automotive ? (Apple Car?) - who knows?!

Page 5: LAP2 iOS and Android Development environment setup

Apple ecosystemCloud services: iCloud

• the “glue” that connects the different systems (documents sharing, Continuity)

App and Mac Stores

• revenue model 30/70

• Developer Program (for app store): 99 euro/year

Page 6: LAP2 iOS and Android Development environment setup

Apple Developer toolsTwo programming languages for all the 4 platforms (iOS, watchOS, OS X, tvOS):

Objective-C (Objected oriented extension of the C language)

Swift (introduced in 2014, open sourced in dec 2015, eliminates the heritage of C and brings in the best features of modern programming languages - clousure, functonal programming, type inference, optionals, etc)

Page 7: LAP2 iOS and Android Development environment setup

Apple Developer toolsObject oriented Native API (Application Programming Interface)s:

Cocoa (OS X)

Cocoa Touch (iOS, tvOS, watchOS)

Cocoa APIs are organized in frameworks:

UIKit, NSKit, Core Data, Core Location, Map Kit, Core Motion, Core Image, Core Audio, Core Animation, OpenGL, etc

Page 8: LAP2 iOS and Android Development environment setup

Apple Developer toolsOne IDE (Integrated Development Environment):

Xcode

Instruments

Design Patterns:

MVC (Model View Controller)

Target-Action, Delegation, Key-Value Observer

Page 9: LAP2 iOS and Android Development environment setup

iOS dev env requirementsDevelopment supported on OS X only

Download Xcode from the Mac App Store:

https://itunes.apple.com/it/app/xcode/id497799835?mt=12

Create a free Developer account here:

https://developer.apple.com/account/

it requires an Apple ID

Page 10: LAP2 iOS and Android Development environment setup

Demo

iOS HelloWorld in Swift

Page 11: LAP2 iOS and Android Development environment setup

Android ecosystemGoogle doesn’t produce hardware directly (LG, HTC)

Many hardware vendors can use Android OS:

Android OS on smartphone, tablets, wearable, set top box (Android TV)

Play Store

30/70 revenue model; $25 una tantum

Page 12: LAP2 iOS and Android Development environment setup

Androd dev toolsProgramming Language:

• Java (C++ with NDK)

IDE (Android Studio e SDK CLI)

Android APIs and Google APIs (maps for example)

Page 13: LAP2 iOS and Android Development environment setup

Android dev env requirementsDevelopment supported on OS X, Windows and Linux

Two options:

• Android Studio (IDE with Android SDK)

• Command Line tools with Android SDK

• Requirements and download at:

• http://developer.android.com/sdk/index.html

• Java JDK (>= 1.6; 1.8 recommended)

Page 14: LAP2 iOS and Android Development environment setup

Android SDK ManagerManages and keep updated Android SDK versions and Virtual Devices (AVDs)

download at least:

Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools

Android 6.0 (API 23): SDK Platform, Google APIs, Google Intel x86 (or 64bit) System Image

Android Support Library, Google USB Driver, Intel x86 Emulator Accelerator (HAXM)

Page 15: LAP2 iOS and Android Development environment setup

Android EmulatorsFamous to be quite slow. Options:

• in dec 2015, Android Emulators 2.0 based on Intel HAXM (virtual emulation layer)

• Genymotion (https://www.genymotion.com) free for personal usage

Install HAXM (to be manually installed after the download with the SDK Manager)

C:\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager

Page 16: LAP2 iOS and Android Development environment setup

AVD creationLaunch the SDK Manager->Tools->Manage AVD

Create a new AVD

• Device: Nexus 4

• Target: Android 6.0 - API Level 23

• CPU/ABI: Google API - Skin: No Skin

• Emulator Options: Use Host GPU

Page 17: LAP2 iOS and Android Development environment setup

The $PATH or %PATH% env variable should contains:

• $HOME/android-sdk/tools:$HOME/android-sdk/platform-tools (Mac)

• C:\android-sdk\tools;C:\android-sdk\platform-tools (Windows)

You should be able to launch the android.bat (or android.sh) script from any dir. Try it

Setting PATH for Android tools

Page 18: LAP2 iOS and Android Development environment setup

HelloWorld for AndroidCreate a project dir and change to it:

• ex. C:\labs; cd c:\labs

Take a look to the available Android targets and choose one:

• android target list

Create a new HelloWorld project with:

• android create project --activity HelloWorld --package it.unict.dmi --target 2 --path C:\labs\HelloWorld

Page 19: LAP2 iOS and Android Development environment setup

Installing and configuring ANTAndroid SDK Command Line use Apache Ant by default. You need to download and install it from

• http://ant.apache.org/bindownload.cgi

Unzip it somewhere (i.e.: C:\android-sdk\apache-ant-1.9.7\) and add the bin folder to the %PATH% env

Check that %JAVA_HOME% env variable points to the Java SDK (and not JRE)

Page 20: LAP2 iOS and Android Development environment setup

Build HelloWorld for AndroidChange the directory to the folder of the HelloWorld project and run:

• ant debug

Have a look to the HelloWorld/bin folder:

• you will find two APKs (Android Packages) ready to deploy to the Emulators and/or physical device

Page 21: LAP2 iOS and Android Development environment setup

Deploy to the Emulators

Launch the Android AVD

• from the Android SDK Manager

• or with emulator -avd <name_of_avd>

deploy with:

• adb install C:\labs\HelloWorld\bin\HelloWorld-debug.apk

Page 22: LAP2 iOS and Android Development environment setup

Deploy to a physical deviceOver the AIR (OTA):

• send the .APK file via e-mail as attachment or save to Dropbox/Google Drive/etc

Via USB:

• you need to enable Debug USB on your device’s settings (Developer menu)

• if the developer menu doesn’t appears, tap 7 times on the Android build number

Page 23: LAP2 iOS and Android Development environment setup

Demo

Android HelloWorld in Java

Page 24: LAP2 iOS and Android Development environment setup

Home assignmentConfigure your machine with all the needed SDK and tools

Build and deploy the HelloWorld app for iOS or Android (or both)

In case of help, ask first your colleagues in the group or me.

Page 25: LAP2 iOS and Android Development environment setup

Any questions ?