1 / 21

MMUG-Dublin Colm Brazel

MMUG-Dublin Colm Brazel. Android on Nexus One September 2010. Introduction.

read
Download Presentation

MMUG-Dublin Colm Brazel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MMUG-DublinColmBrazel Android on Nexus One September 2010

  2. Introduction • Android 2.2 was introduced at Google's own I/O conference in San Francisco this past May, promising to add a number of much-wanted changes and even a few things that iOS does not support. Its an Open Source Linux based OS that rivals Apple’s iPhone • http://hothardware.com/Reviews/Android-22-Review-A-Deep-Delicious-Dive-Into-Froyo/ • This preso I’ll demo building a simple app in both Android and Air to show the workflow between software and phone. I’ll focus on the typical software and hardware environment with Froyo on Nexus One required for setup and development of Android applications provided by Eclipse , FlashPro CS5 platform provided by Adobe. Included is a brief introduction to the use of the Google API. • Adobe Integrated Runtime (AIR) is a cross-platform runtime environment developed by Adobe Systems for building rich Internet applications using Adobe Flash, Adobe Flex, HTML, or Ajax, that can be deployed as a desktop application. • Android has become one of the most innovative mobile operating systems available, with many aspects eclipsing iOS from Apple. Android 2.1 is an extremely refined OS, with multiple home screens, full multi-touch support, the world's best smartphone turn-by-turn navigation system (Google Maps Navigation)  and the ability to "sideload" applications and music.

  3. Continue • Download Java sdk /install it • Look for latest 64 bit sdk or get it here/+install instructions: http://www.oracle.com/technetwork/java/javase/downloads/index.html • Click Start (win 7)Right click computer\properties\click advanced\advanced system settings\advanced\environment variables and add the following to path variable ( eg assuming you installed at following location ) • Java;C:\Program Files (x86)\Java\jdk1.6.0_17\bin (for x86 if you have not 64 bit version) • C:\Program Files\Java\jdk1.6.0_21\bin (if you have 64bit) • (TIP) Note sdk can automatically install updates include version info that mean your path variable may require updating. Note another method for working with the sdk tools with cmd prompt given here shortly. • Download and install the Android SDK full instructions for your OS install given here: • http://developer.android.com/sdk/index.html

  4. Configuring Nexus One • Full update instructions Android 2.1 to Froyo, 2.2 USB at following link. Install is a typical Win 7 install example. Follow the steps outlined here: Android 2.2 Install on Nexus One • You need Android USB Drivers to manage your computers cable connection to the phone: These may be updated from Eclipse, Window\Android SDK & Download Manager\ Download relevant USB 3 packages. Alternatively, use drivers from supplied Android SDK, go to start/right click Devices & Printers and update your drivers for Nexus One to your 2.2 new drivers, or simply copy/paste the supplied USB drivers in your android SDK USB .dll drivers into windows/system32 • If not already connected by USB cable connect USB cable to laptop. • Turn on USB debugging and tethering on your phone. • Settings/Applications/Development/USB Debugging • Settings/Wireless networks/Tethering & Portable hotspot turn on also. • TIP(Debugging on device much faster than on AVD emulator) • TIP(Connection difficulties? Double check connection/reattach/recheck settings) • Open cmd prompt on computer go to tools folder of sdkand look for output from the following command: • C:\android\android-sdk-windows\tools\ adb devices • The signature id of your device should appear in the cmd prompt window

  5. Check out CMD/adb/DDMS Debugger • Try these commands from command prompt: • Cmd prompt • Cd android/android-sdk-windows/tools/adb • Cd android/android-sdk-windows/tools/adb devices • Cd android/android-sdk-windows/tools/adbshell Shell gives command window to use linux commands egls • Cd android/android-sdk-windows/tools/logcat • Cdandroid/android-sdk-windows/tools/sqlite3 Checkout sqlite3 library information here: http://www.sqlite.org/ • Play with emulator here http://developer.android.com/guide/developing/tools/emulator.html • TIP(Disconnect/reconnect usb phone cable to double check a possible problem with connection) • $ exit

  6. How do I learn to programme with Eclipse and Android • http://android.voxisland.com/ for complete set of training videos with accompanying documentation and nb downloadable projects to examine in Eclipse. • http://eclipsetutorial.sourceforge.net/totalbeginner.html NB, learn how to work with Java on eclipse also nbJUnit testing (not covered in these notes) • http://developer.android.com/sdk/adding-components.html • Following Android install the Android option is now available to you. • Eclipse File/New Project/Android/Android Project • Choose a target API to build against in the drop down API list eg Android 1.6 NB You have the following options; 1) Create new Project; 2)Create project from existing source (great if you've downloaded sample projects from the internet you wish to study/examine; 3) Creat Project from existing sample ( great as this defaults to the location of the Android samples folder and you want to examine these ) • Option 1 requires some settings information you need to fill in. A package groups related classes, interfaces and subpackages within a unique identifier. Using a windows folder analogy, lets consider all tyour project files grouped into one folder. There's a possiblility on the internet your code could be overwritten with other code of the same name. So the solution is to give a unique identifier by convention is your website domain name in reverse as in com.mywebsite.

  7. Sample Settings Building New Projects • Build Target: Android 1.6 • Give your project a name: Oliver Goldsmith • Application Name: Oliver Goldsmith • Package Name: com.mywebsite • Create Activity: Biography • Min SDK version: 4 (refers to API Level of build target) • You can also do File import/Existing Project from Android workbench • Your project is created • Android SDK and Update Manager/Create new AVD (Android Virtual Device) connection. Note the different AVD application GUI’s available for testing applications against different devices with different capabilities. • When project files are generated in your workspace, right click project folder, run as, android project • Checkout Window/Android SDK and AVD Manager and Window/Preferences locations for further options.

  8. Recap Android Developer Downloads (Sample setup explored for Win 7 and Nexus One) • Download /Install Eclipse http://bit.ly/agLSXK • Download /Install Java SDK http://www.oracle.com/technetwork/java/javase/downloads/index.html • Download /Install Android SDK http://developer.android.com/index.html • Open Android SDK and AVD Manager. Look for available packages. Download USB drivers. No need for this if on Mac. • Go to sdk/tools ….You work mostly with ADB application • http://eclipsetutorial.sourceforge.net/totalbeginner.html Eclipse and Java TotalBeginnertutorials • Java totalBeginner tutorials of particular value learning Eclipse/Java and JUnit testing not explored here • 5. http://developer.android.com/guide/topics/manifest/manifest-intro.html

  9. Some Android Tutorials • http://whyandroid.com/ • http://androidcore.com/code_files/android-tutorial-for-beginner.pdf • http://whyandroid.com/images/android%20-%20Getting%20Started.pdf • http://android.voxisland.com/ • Voxisland Recommended

  10. Working with Android SDK Tools Continued • Connect Nexus One via USB cable • In Android SDK tools, shift key and right click to open command prompt. • In CMD type> adb devices • In CMD type> adb note the other adb command parameters available • Get some AIR • http://labs.adobe.com/technologies/air2/android

  11. New Project Samples & Button • File/new project/Android Project etc • Note the workflow moving from xml to java to testing to debugging, see presosample and nbvoxisland tutorials for application development workflow examples. • Resources/Layout/main.xml • Code manifest file if you need • Good practice creating strings • Create sample button application to test your environment and workflow/AVD or on device, launch it. • In the main.xml file in layout folder and in src package folder working with your java initialisation and constructor file, experiment with Eclipse code assist, debugging, quick fix works. Voxisland again.

  12. Working with Android/Google Application Certificates/KeysUsing the API key in your application • NB to obtain Google API key needed to access/use the Google API in your applications, follow the following procedure: • Open Android Manifest file • Use Export wizard to export and sign an APK, fill out info in form • Select destination of your apk plus cert • Read: • http://code.google.com/android/add-ons/google-apis/mapkey.html • Once you have located the keystore, use this Keytool command to get the MD5 fingerprint of the debug • certificate: • $ keytool -list -alias androiddebugkey \ -keystore <path_to_debug_keystore>.keystore \ -storepass android -keypass android

  13. To Develop with Google Api Your Applications Require Google API Key • http://code.google.com/android/maps-api-signup.html • Eclipse/Window/Prefs/Android Build (To get location of Android keystore) • C:\Users\Colm\.android\debug.keystore • Run cmd and use eg: • c:\>cd C:\Users\Colm\.android • (TIP) On windows 7 by holding shift and right-clicking a folder, you'll see additional commands not listed on the standard menu, such as open in new process, copy as path, and open command window here. • With this information, you get location of keystore below and run the command from a cmd prompt window generated from within the bin directory of your current sdkexample here following location used from above: • C:\Users\Colm\.android\debug.keystore • In cmd (use shift + right click) prompt opened from your java sdk bin directory This will generate a command window in your bin folder. Using info above here’s example of the code use to generate MD5 fingerprint of the certificate that you will use to sign your android apps nb required for application for Google API Key code your application will need to access the Google API service. See sample code below: • C:\Program Files\Java\jdk1.6.0_21\bin>keytool -list -alias androiddebugkey -keystore C:\Users\Colm\.android\debug.keystore -storepass android -keypass android • The following return message is generated: • androiddebugkey, 08-May-2010, PrivateKeyEntry, • Certificate fingerprint (MD5): 21:97:Z8:FE:21:B2:58:A3:33:F4:39:11:81:5C:E4:D6

  14. Working with Google API continued • http://code.google.com/android/maps-api-signup.html • My certificate's MD5 fingerprint: Paste your generated MD5 fingerprint here • All going well you should be taken to another screen with content similar to the following: • Thank you for signing up for an Android Maps API key! • I’ve changed the APIKey fingerprint and key but should look similar to following: • 03WKLn1CBk44f6AdqV05J7QQmzrz9aBoOke46dZ This key will work for all apps signed with your certificate whose fingerprint is: • 21:27:B8:aE:29:B2:58:AB:33:F4:19:11:01:2C:14:96 Here is a sample xml layout to get you started on your way to mapping glory: • <com.google.android.maps.MapViewandroid:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="03cKLx1CBk98f6AcqV05J8bQmzru9zBoOke46dz" /> • apiKey, copy that key to your MapView.xml • Launch a suitable AVD, or try it on your device!

  15. Working with Adobe Air • http://labs.adobe.com/technologies/air/ • Lee Brimlow full setup tutorial here http://www.gotoandlearn.com • Home/Sign Up for Adobe Air Pre Release • Already signed up find prefilled pwd/apply to login • Free extension for Flash CS5 available • Welcome to Adobe for Air Developer Pre Release site resources/forums/documentation • Download Software

  16. Install Air Android on phone • Right click, save link as, to save Froyo APK files, both runtime and emulator to Android SDK tools directory • In cmd prompt in Android tools SDK> adb install nameOfPkgRuntime.apk • Wait for success • Go to tools and run ddms.bat (Dalvik Debug Monitor) • http://www.adobe.com/support/documentation/en/air/2_0_3/releasenotes_developers.html Note from here info on: • NB Permission code that must be added to accompanying companion .xml release file added as part of the .apk file produced in your application, if Air application wishes to access services services eg camera on the phone. Brimlowwww.gotoandlearn.com for example setup, his 2nd tutorial on Air On Android demoing how to access camera through Air.

  17. Download Air Flash CS5 extension • Install AIRforAndroid_FlashCS5_20100802 with Extension Manager • Help http://www.nexusoneforum.net/forum • Read Release Notes in supplied .pdf for specific instructions e.g right click Adobe Extension Manager and run as administrator. Ensure Flash Pro CS5 is closed. • For any install issues or help http://forums.adobe.com/community/air/development • This now gives you the option in Flash CS5 to use a default template 480px * 800px to publish your flash application directly to your phone device. • Open it and develop a test application. Follow good practice for building mobile applications re file size, avoid use of 3d/gradients and avoid methods that will unnecessarily burden the cpu/frame rate of your app. Note Flash 10 allows for deployment of Air applications onto your sd card to allow for bigger size apps that will not burden the kernel memory of your phone. • File/Publish settings/flash/Air Android/Deployment • Choose options for generating a certificate and deployment onto your device for debugging\or release onto your device. • Enjoy how easy it is to develop Air applications for your device

  18. Continued • https://prerelease.adobe.com Pay particular attention to documentation on manifest.xml settings for AIR. These permissions will have to be set to allow phone connections to e.g camera services such as camera. • Current file is AIR_Android_ReleaseNotes_0826.pdf • Access camera with • <android><manifestAdditions><manifest><data><![CDATA[<uses-permission android:name="android.permission.INTERNET"/>]]></data></manifest></manifestAdditions></android> • Also documentation on: • Mapping Android specific tags from app-xml to Android Manifest • This feature allows developers to set some Android specific tags within the android manifest xml. To do this the developer needs to mention his preferences within the android tag in app-xml and these options shall be then set within the Android Manifest xml. Details about Android Manifest xml can be found here. Some tags that can be useful are Manifest attribute installLocation allows the installed application to be installed on either phone memory or sdcard. This can help developers whose application apks are large in memory size.

  19. Working with Google’s API • http://developer.android.com/guide/publishing/app-signing.html • Extracts from documentatio follow here for reference example only: • http://code.google.com/android/add-ons/google-apis/maps-overview.html#apikey • To use the classes of the Maps external library in your application, you need to: • Install the Google APIs add-on, as described in the Installing document. If you are using the Android SDK, you don't need to install the add-on — it's preinstalled in the SDK package. • Set up a new Android project — or reconfigure an existing one — to build against the installed Google APIs add-on • Set up an Android Virtual Device configuration that uses a the Google APIs add-on • Add a uses-library element to your application's manifest file, to reference the Maps library. • Use the Maps classes in your application • Get a Maps API Key, so that your application can display data from the Google Maps service. • Sign your application properly, using the certificate that matches your API Key. • Getting a Maps API Key • If you aren't familiar with how Android applications are signed, please see Signing Your Applications on the Android Developers site. • MapView objects display Maps tiles downloaded from the Google Maps service. Before you can use Google Maps data, you must register with the Maps service, agreeing to the Terms of Service and supplying an MD5 fingerprint of the certificate(s) that you will use to sign your application. For each registered certificate fingerprint, the service provides you with a Maps API Key — an alphanumeric string that uniquely identifies you and your certificate. You then store your API Key in your MapView objects, so that when they request Maps data, the server can determine that you are registered with the service. • For full information about how to get and use a Maps API Key, see Obtaining a Maps API Key. • If you do not store a valid Maps API Key in your MapView elements, you can still compile and run your application, but your MapView elements won't be able to display data from the Maps server. For this reason, you should register for an API Key as soon as possible, once you begin development. Registering is free and takes only a few minutes. • Keep in mind that each Maps API Key is uniquely associated with a specific signing certificate. That means that: • When you are getting started on developing, you can register using the debug certificate created by the SDK tools. • When you are ready to publish your application, you need to register again using the certificate with which you will sign your application for release. You must then update your MapView elements so that they reference the release API Key, rather than the debug Key, and then sign your application with your release certificate.

  20. Tips • If no error is showing, try deleting error message from console, use delete key. • Then do a project\clean • Line numbers.. 1) Windows -> Preferences2) General – > Editors -> Text Editors and click the “Show Line Numbers” checkbox. • Start up an emulator, make a new one if not already there. Launch from Window/Android SDK and AVD Manager • From c:\android\android-sdk-windows\tools • Check c:\android\android-sdk-windows\tools\adb devices • Adb shell • This gives a # console input • Use linux commands egls or • Logcat.exe ………… keep running during session • Checkout stacks/heaps/trace debugging with method profiling from DDMS

  21. End • Summary: Download install, Eclipse, Java sdk, Android sdk, Air Runtime for Android, flash CS5 add on for Air export. Configure per docs. And • Learn some java http://eclipsetutorial.sourceforge.net/totalbeginner.html • Learn some Android http://android.voxisland.com/ • Download and Install the android samples from the android sdk into Eclipse and examine code • Learn some Flash/Android http://www.gotoandlearn.com • Play with some Google mapping API’s for Android and Flash http://code.google.com/apis/maps/index.html • Make some great applications. • Thanks for supporting MMUG-Dublin • 

More Related