Thursday, September 29, 2011

Google Android Development with Flash Builder - Preparation Guide

This is the third in a series of articles explaining how to set up your development environment to prepare for attending my Adobe MAX preconference hands-on code camp.  The previous articles covered setting up Flash Builder and devices for iOS Application Development and BlackBerry Tablet OS development with Adobe Flash Builder.

In this post, you will learn how to set up Flash Builder and your Google Android device (running Android 2.2 or later) to get ready for development.

1.  The first step is to install Adobe AIR on your device if you have not already done so.  Simply visit the Android Market on your device, search for Adobe AIR, and complete the free install.  Here's a link: https://market.android.com/details?id=com.adobe.air&hl=en

2.  Next, you need to enable USB debugging on your device.  From the Home screen, tap Settings, and then select Applications > Development. Enable the USB debugging option.  If there is an option to stay awake while charging, enable that too.  NOTE:  This cannot be set while your phone is tethered to your computer.  Unplug the mini-usb cable before setting this.





3. If you're running Windows, you'll need to set up a USB device driver for your device.  For more information on this, see Connect Google Android Devices.   Depending on which version of Windows you're running and what Android device you have, the device driver set up can take some time.

This AdobeTV video by Platform Evangelist Bhakti Pingale walks through the setup steps for a Samsung Galaxy Tab: http://tv.adobe.com/watch/adc-presents/mobile-device-debugging-using-usb/.

4.  Plug your phone into your computer and open Adobe Flash Builder 4.5 or later.

5. Choose New > Flex Mobile Project and give your application a name.  Ensure that the defaults are selected as shown below.


6. Click Next and ensure that under Mobile Settings the Google Android checkbox is checked.  If you are only developing for this one platform, deselect the others.   Click the Permissions tab and ensure you have the appropriate permissions selected for each item you want to use.  For example, if your  app needs to use the Internet and access the camera on a Google Android device, you must select the permissions as shown below.


7. If you are building for both Tablet and smart phones, your application will have to be scaled for different screen densities and sizes.  I usually select the Scale Up From 160 dpi checkbox.  Click Finish.

8. Build your application.  If you want to see how easy this is, open the file created under the Views package, switch to Design view, and add a button.  Double-click the button to change the name to something unique (like "Hello Technoracle").  If you are looking for some easy tutorials for mobile application development, please download the course from http://www.22ndcenturyofficial.com/MAX2011/BL3453-ALL.zip

9. Once your application is complete, you may wish to release it to the Google Market.  To do this, you first need to make a proper certificate.  This process is described in this blog post on generating a P12 certificate for the Google Market using the Adobe AIR SDK.

10. When your application is complete, choose File > Export.  In the dialog box that appears, select Flash Builder > Release Build and click Next.

11. Ensure that the correct project is selected in the next screen along with the proper path location at which you wish to place your APK file.  APK files are the install packages for Google Android.  Also ensure that the Signed Packages For Each Platform setting is checked and click Next.

12. A screen will appear asking you for the location of the certificate and password that you created in step 9 above.  Fill these in and click on the deployment header and ensure that Install And Launch Application on Any Connect Devices is checked.  Make sure your Android device is connected and click Finish.


That is it!  Your application will compile into an *.APK file and install itself on your Google Android device.  If your application was built with a simple button it will appear and run as shown below.



Your application can be placed in the Google Market by creating an account and following the instructions at https://market.android.com

2 comments:

  1. Is there a way to get Flash Builder to create an APK file that can be used with the Android Emulator? The APK created by the Release Build functionality seems to only work on actual devices, and cannot be installed on the Emulator.

    ReplyDelete
  2. I have not done this but the reason could be that the APK file created by Flash Builder is actually an AIR file dressed up to look like an APK. When it gets launched, it has a small bit of code packaged with it that can be interpreted by the Dalvik virtual machine with just-in-time compilation to run compiled Java code. This code tells the system to launch Adobe AIR as the intermediate runtime. If you do not have Adobe AIR in the Google Emulator, it probably would not run AFAIK. Caveat - I have not tried this yet but it would make sense.

    OTOH, the Flash Builder Emulator is fairly awesome IMO. Duane

    ReplyDelete

Do not spam this blog! Google and Yahoo DO NOT follow comment links for SEO. If you post an unrelated link advertising a company or service, you will be reported immediately for spam and your link deleted within 30 minutes. If you want to sponsor a post, please let us know by reaching out to duane dot nickull at gmail dot com.