View
715
Download
0
Category
Preview:
Citation preview
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
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
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?)
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?!
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
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)
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
Apple Developer toolsOne IDE (Integrated Development Environment):
Xcode
Instruments
Design Patterns:
MVC (Model View Controller)
Target-Action, Delegation, Key-Value Observer
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
Demo
iOS HelloWorld in Swift
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
Androd dev toolsProgramming Language:
• Java (C++ with NDK)
IDE (Android Studio e SDK CLI)
Android APIs and Google APIs (maps for example)
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)
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)
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
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
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
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
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)
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
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
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
Demo
Android HelloWorld in Java
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.
Any questions ?
Recommended