- Know about the essential tools in the Android SDK
- Get familiar with the development environment
- Create and start a virtual Android phone using the Emulator
What is Android? 3
- Open source
- Linux kernel
- Optimized for mobile devices
- Uses Java for building applications (1.5)
- Can also run native code in C/C++
- Has its own runtime (not standard Java runtime) - Dalvik
- 2003 Android, Inc founded by Andy Rubin and others
- 2005 Google buys Android, Inc
- 2007 Apple launches the iPhone
- 2007 Google announces Android
- 2008 First phone available for purchase (HTC Dream)
- 2010 Apple launches the iPad
- 2011 Android tablet version and largest update 4.0
- Android versions has three naming conventions
- Named after sweets/pastries in alphabetical order
- Named according to standard software major/minor versions
- Named after sequential number
- Most important versions
|Ice Cream Sandwich||4.0.3||15||2011|
Version Features 6
- 2.1 Eclair
- Live wallpapers. Account Manager.
- 2.2 Froyo
- Store apps on SD card. Cloud to device messaging.
- 2.3 Gingerbread
- Multiple cameras. Gyroscope and more sensors.
- 3.X Honeycomb
- Fragments. Action bar. New animation framework. For tablets only.
- 4.0.3 Ice Cream Sandwich
- GridLayout. Resizable widgets. WiFi Direct.
- 4.1+ Jelly Bean
- Multi-user support. Lock screen widgets. Second display support.
- 4.4 KitKat
- WebViews uses Chromium, Immersize mode, Translucent ActionBar
Android SDK 7
- Contains tools and files necessary to build Android applications
- Possible to build applications with only the SDK and its command line tools
- Recommended to use an IDE (Integrated Development Environment)
- Many, if not all, tools require Java to run
- Android SDK Manager
- Download further components and update the existing tools
- Android Virtual Device Manager
- Create virtual phones with different screen sizes and other features
- Android Emulator
- Run a virtual phone created with the Virtual Device Manager
- Show and investigate the insides of a running phone, physical or virtual
Android SDK Manager 9
- Download and update components of the SDK
- Menu/button in development environment (Eclipse or Android Studio)
- Run "android sdk" from the command line inside the tools directory of the SDK
- On Windows, you can also start "SDK Manager.exe"
- SDK Platform
- A specific version of the Android operating system for building and running apps
- Google APIs
- A specific version of the Android operating system including Google specific APIs (maps)
- ARM EABI v7a System Image
- A binary for running virtual phones in the emulator, emulating the ARM processor (slow)
- Intel x86 Atom System Image
- A binary for running virtual phones in the emulator using native Intel processor (faster). For this to work you also need to install the Intel x86 Emulation Accelerator.
- Google Play Services
- Not used in the course, but contains a lot of extra APIs not available in the operating system
- Intel x86 Emulation Accelerator (HAXM)
Android Virtual Device Manager 10
- Tool in the SDK to create virtual devices and then launch them inside the Android Emulator
- Menu/button in the development environment (Eclipse or Android Studio)
- Run "android avd" from the command line inside the tools directory of the SDK
- Create new virtual devices
- Choose an Android version for the phone
- Choose an image (ARM or possibly x86 emulation)
- Choose memory and other features
- Start a virtual device in the Android Emulator
Android Emulator 11
- Very close to a real device
- Slow to start. Ok to use (hopefully). Keep it open!
- Specify "Hardware keyboard" to type using your computer keyboard
- Physical buttons on a physical device will be extra buttons in the Android Emulator window
- Can be scaled/resized when running on computers with smaller screens
- Each running emulator has a local tcp port number for control/communication
- adb is a command line tool to communicate with the emulator
- Multiple running emulators can "call" each other using the port number
Common errors 12
- Syntax errors in layout xml file
- Typing wrong element or attribute names in the xml file is common and are usually not discovered until starting your application. Note that most names are case sensitive. Also note that most attributes is prefixed with "android:". The exception thrown is seldom helpful.
- Wrong onClick method
- If the value of the "android:onClick" attribute does not match the method in your Java class, this is not discovered until the application runs. The name much match exactly, including case, but the method must also be "public void" and take a View as its single argument.
- Forgetting to request a permission
- Some operations like performing a network request requires a permission to be specified in your AndroidManifest.xml file. Without it, an exception will be thrown the first time network communication is attempted.
- Forgetting to declare extra Activities
- If your app has more than one Activity, it is common to forget that besides creating a layout xml and an Java source code file you also need to declare it in AndroidManifest.xml.
Faster Android Emulator 13
- Android Emulator is slow
- Because it is as close to a physical device as is possible. A full compile of the Android platform for ARM processors. Since it needs to emulate the ARM processor, it will always be slow.
- Not always a bad thing. The advantage is that the speed of emulator will not fool you with regards to how fast your code will run on physical devices.
- Use a x86 image instead
- A full compile of the Android platform, but for Intel x86 processors
- This will be faster since it means that no ARM processor emulation is necessary
- Requires installation of "Intel x86 Emulator Accelerator (HAXM)"
- Install it from the Android SDK Manager (under Extras). Requires administrative access on your computer.
- Then install "Intel x86 Atom System Image" for the Android version
- And create a virtual device that uses the "Interl x86..." image instead
Deciding on an Android version 14
- One single application
- Can run on many different Android versions
- Can check and adjust itself to take advantage of newer features on newer versions
- Multiple versions of the application
- Build separate applications with different "Minimum Required" versions
- Some/much shared code
- Two versions should cover most of the needs for version separation
- If there is a specific feature your application requires in order to function
- If there are features that will enhance your application, but isn't essential
- Statistics of running versions
DDMS (Dalvik Debug Monitor Server) 15
- Communicates with a running Emulator or actual Phone/Device
- Take screenshots from the device
- Transfer files to/from the device
- Show logs and debugging messages
- Show status information about processes
- Show network usage
The resulting app 16
- The resulting file from building a complete app is an apk file
- The apk file is actually a zip file with compiled code, resources and more
- The apk file can be transferred to a physical phone via USB and the DDMS or development environment
- The apk file can also be downloaded and installed from any web site, if allowed in system settings (Unknown Sources)