MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building,...
-
Upload
vladimir-kulyukin -
Category
Technology
-
view
140 -
download
0
Transcript of MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building,...
![Page 1: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/1.jpg)
MobAppDev
Android Installation, Android App Anatomy, Coding Lab, Building,
Running, & Signing Apps
Vladimir KulyukinDepartment of Computer Science
Utah State University
![Page 2: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/2.jpg)
Outline● Android AppDev Infrastructure: What is What and What
Installs Where (Most Likely)● Android App Anatomy: Components of an Android
Application● Coding Lab● Building, Running, & Signing Android Apps
![Page 3: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/3.jpg)
What is What &
What Installs Where
![Page 4: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/4.jpg)
Android Root Directory on WindowsAfter you install Android on Windows, your Android root directory will, most likely, look as shown below
![Page 5: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/5.jpg)
Android Root Directory on Linux
After you install Android on Linux, your Android root directory will, most likely, look as shown below
![Page 6: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/6.jpg)
Android Root/add-ons● /add-ons - 3rd party releases of Android; add-ons may require
some licensing agreement (make sure you understand licensing before adopting an add-on)
● The most important sub-directories of an add-on are: /images – system image files for Android devices
(ramdisk.img) /libs – JAR files you need to include in your projects
(e.g., maps.jar) /samples – if present, contains sample projects with
source code (e.g., MapsDemo)
![Page 7: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/7.jpg)
Android Root/platforms
● /platforms – specific platforms installed on your system (e.g., android-8, android-10, android-19, etc)
● Each platform directory will have, at least, the sub-directories: / data, / images, & / skins
/ data – various resources (e.g., fonts, icons, etc) / skins – looks of devices / templates - template XML and image files
![Page 8: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/8.jpg)
Android Root/samples & /platform-tools● /samples – sample projects for specific platforms● /samples are a great way to learn Android development tricks
(many of them are not well documented: you build them, run them, & study the source, modify it, etc)
● /platform-tools are applications and libraries you need for Android development
aapt (Android Asset Packaging Tool) moved to /build-tools/ adb (Android Debug Bridge) aidl (Android Interface Definition Language compiler) moved
to /build-tools/
![Page 9: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/9.jpg)
Android Root/sources● /sources – source code from various companies and
organizations (may not install in Windows) ● /tools are applications and libraries you need for running and
debugging Android apps emulator ddms (Dalvik Debug Monitor Server) hierarchyviewer (UI debugging and opitmization tool) sqlite3 (SQLite tool for inspecting SQLite databases)
![Page 10: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/10.jpg)
Tool Access & Versions
● Android Plugins for Eclipse make most ADK tools available from within IDE
● If you are a command line developer, you may want to add / platform-tools and / tools to your PATH
● Android APIs tend to be backward compatible (modulo hardware restrictions) but some APIs do get depricated: you have to stay current on what is current on your target Android platform
![Page 11: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/11.jpg)
Android App Anatomy
![Page 12: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/12.jpg)
Greeting & ToastingGingerbread (Android 2.3.X)
& Jelly Bean (Android 4.2)
download source HelloGingerbread, HelloJellyBean
![Page 13: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/13.jpg)
Hello to & Toast on Gingerbread
![Page 14: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/14.jpg)
Hello to & Toast on Jelly Bean
![Page 15: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/15.jpg)
Android App/AndroidManifest.xml
● AndroidManifest.xml is the glue that specifies & holds your app together (conceptually similar to Unix/Linux make files)
● Specifies your app's package, minimum & target SDK versions, your application and activities inside your application
![Page 16: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/16.jpg)
Android App/gen
● /gen folder contains all auto-generated Java source
● You should not modify it● R.java is a very important
class that defines constants that you need to programmatically access various elements of your application
![Page 17: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/17.jpg)
Android App/assets, /bin, /libs, /res
● /assets - arbitraty user created files or file hierarchies not available through R.java
● /bin - .dex (Dalvik byte code), .apk and drawables
● /libs JARs for required by the app● /res – XML and drawable resources
available through R.java
![Page 18: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/18.jpg)
Android App/res
● /res folder contains XML resources and drawables of various resolutions required for your app
● /res/drawable-xxxx - drawables of various resolutions
● /res/layout - XML UI specs for activities● /res/menu – XML menu specs for activities● /res/values – XML definitions of string
constants and styles
![Page 19: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/19.jpg)
Pushing/Pulling Files To/From Device
Open DDMS Perspective, Select Device in the left panel; click on 'Push File To Device' or 'Pull File From Device'
![Page 20: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/20.jpg)
Coding Lab
![Page 21: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/21.jpg)
Problem
Develop an Android application with a custom icon and a custom background. The main screen has one button that toasts a random quote from a list of quotes. The same quote also is written in the LogCat console.
![Page 22: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/22.jpg)
Building, Running, & Signing Android Apps
![Page 23: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/23.jpg)
Building & Running Apps● Eclipse ADT plugin builds your app incrementally as you make
changes to it (check Project | Build Automatically menu option)
● The .apk file is saved in the /bin folder● It is possible to develop in non-Eclipse environments: you can
use the generated build.xml Ant file in the project directory● The app must be signed (debug or release mode) to run on an
AVD or a device● Eclipse ADT automatically signs your app in debug mode
![Page 24: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/24.jpg)
Building & Signing AppsBuilding Apps Signing Apps
![Page 25: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/25.jpg)
Building & Running Steps
www.vkedco.blogspot.comwww.vkedco.blogspot.com
![Page 26: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/26.jpg)
Building & Running Apps● Eclipse ADT plugin builds your app incrementally as you make
changes to it (check Project | Build Automatically menu option)
● The .apk file is saved in the /bin folder● It is possible to develop in non-Eclipse environments: you can
use the generated build.xml Ant file in the project directory● The app must be signed (debug or release mode) to run on an
AVD or a device● Eclipse ADT automatically signs your app in debug mode
www.vkedco.blogspot.comwww.vkedco.blogspot.com
![Page 27: MobAppDev (Fall 2014): Lecture 02: Android Installation; Android App Anatomy; Coding Lab; Building, Running, & Signing Apps](https://reader035.fdocuments.net/reader035/viewer/2022070321/558e0b2e1a28abc6178b464b/html5/thumbnails/27.jpg)
References● developer.android.com● developer.android.com/tools/building/index.html● http://www.youtube.com/vkedco
www.vkedco.blogspot.comwww.vkedco.blogspot.com