Friday, November 30, 2012

AndroVM Android Virtual Device

After much trial and error, the best solution for my slow Mac is to find an alternative to the QEMU emulators bundled with Android Developer Tools (ADT).

For me, the solution was AndroVM running on VirtualBox.  This will give you a nice fast Ice Cream Sandwich version of Android with the ability to install your apps from the Google Play Store as well as a place to run and test your own apps.

First Download and install VirtualBox from: https://www.virtualbox.org/

Next Download and install the latest AndroVM from: http://androvm.org/
There are several .ova files to choose from for Tablet, Phone and Table or Phone only, with or without the built in Google Apps.  I selected the Phone only version (vbox86p) with Goofle Apps & Houdini.

From VirtualBox, select File -> Import Appliance and select the AndroVM .ova file.
You will now have a VM in VirtualBox ready to run.

If you select Network Settings for this VM, you will notice that there are 4 network adapters.  The first network adapter is not attached and the 2nd adapter is attached to NAT.  Adapters 3 and 4 are not enabled.  In order to connect to this device (once it is running) with the Android developer tools, you will need to attach Network Adapter 1 to "Host-only Adapter"



Fire up the Virtual Android device from VirtualBox by clicking the "Start"
If all goes well, the VM will start and Android will boot up and you will be greeted by the welcome screen asking you to start setting up your new Android (virtual) device.



Run through the setup and you will end up on the home screen where you can start running apps on the new virtual device.



Run the Browser to ensure you have internet connectivity via the NAT Network Adapter.



Now that we have our Virtual Device set up, the next post we will deploy (copy) our HelloGalaxy.apk file onto the virtual device and run our first app.





Tuesday, November 27, 2012

Android File Transfer on Mac with Galaxy S3

I could not get the Android File Transfer app http://www.android.com/filetransfer/ to work on my Mac.
It turns out that Kies application from Samsung was the problem causing conflicts when connecting my S3 to my Mac :(
http://www.samsung.com/us/kies/

You need to un-install Kies using the Uninstaller on the Kies disk image.

  1. Download the Samsung Kies package from the Samsung website:
  2. http://www.samsung.com/uk/support/usefulsoftware/KIES/JSP
  3. Open the downloaded Kies package
  4. Run the "Uninstall" program
The Galaxy device must also be set to "Media Device" Mode (MTP) as this is the protocol used by Android File Transfer. This can be done as follows:
  1. Connect your S3 to your Mac using a USB cable
  2. Touch the notification bar on your phone (the thin bar at the top of the screen containing the time, battery indicator, etc.)
  3. Pull the notification bar down to the bottom of the screen
  4. Select the “Connected as Media Device” or “Connected as Camera” option
  5. Select the “Media Device (MTP)” option (if this is not already selected)

Hope this helps any other frustrated users.  The Android File Transfer App is invaluable.


Building "Hello Galaxy"

In the previous post, we created a new Android project called "HelloGalaxy"using the Android Developer Tools (ADT).
In this post we will build and package the project.  The final package is "HelloGalaxy.apk" file which is really just a jar file that can be installed on an Android device.  The .apk file contains all the code, metadata, icons, etc.which needs to be installed in the /system/apps folder on your Android device.

At first we will want to install and run this on a "virtual" device (i.e. an Android simulator) instead of on a real device.  Sadly the QEMU emulators that come with the ADT are too slow for my Mac.  In the next post we will show how to set up a emulator based on VirtualBox that is much faster.

At this point, we will assume you do not have any emulators configured or running.  To compile, build and generate the HelloGalaxy.apk file, simply choose Run-> Run As -> Android Application.  This will compile, build and package the HelloGalaxy.apk file.




Assuming you have not created any Android Virtual Devices yet, an error message will pop up saying no compatible targets were found, asking if you wish to add a new Android Virtual Device.  Select "No".



After selecting "No", an "Android Device Chooser" dialog pops up.  Click the "Cancel" button.



The build will succeed and the log file will indicate that the Launch was cancelled.



Even though the app did not run, the HelloGalaxy.apk file was generated in your project's bin directory.  This is the file we will install and run on a suitable Android (Virtual) Device.



The APK file is not signed with your developer private key, so you shouldn't distribute or or upload it to the market.

Another way to generate the APK file is to export an unsigned .apk from Eclipse, right-click the project in the Package Explorer and select Android Tools > Export Unsigned Application Package. Then specify the file location for the unsigned .apk.



To see the contents of the APK file, which is simply a jar file, run "jar -tvf HelloGalaxy.apk"  This will list the contents of the package.  You should see the icons, xml metadata files, etc.

In the next post we will show how to set up an Android Virtual Device using VirtualBox and install the APK file onto a virtual device and run our first Droid app.



Hello Galaxy

I made the switch from iPhone to the new Galaxy S3, so now I need to learn to code on Droid.

iOS development was fun and Apple's dev tools rock.  I am sure the journey to build Droid apps will be just as much fun.

Here are my notes into getting "Hello Galaxy" ;) up and running on my Mac.  Here are the specs for my dev machine.



First download the ADT Bundle from: https://developer.android.com/sdk/index.html
This bundle has all the Android SDK components and a version of the Eclipse IDE with built-in ADT (Android Developer Tools) http://dl.google.com/android/adt/adt-bundle-mac-x86_64.zip

Unzip to a "develop" folder and fire up Eclipse.app in .../develop/adt-bundle-mac/eclipse/ folder:

When Eclipse fires up for the first time it will ask you to choose a workspace for your projects.  (I like to create a new workspace in the same place where the tools live).




Close the "welcome"screen and a familiar empty eclipse workspace awaits...


Select File->New Android Application Project


Enter "HelloGalaxy" as the Application Name:

Click Next and keep defaults for the Configure Project. 


Click Next and keep defaults for the Configure Launcher Icon. 

Click Next and select BlankActivity for the Create Activity dialog.

Click Next and keep defaults for the New Blank Activity dialog, keeping the Activity Name as MainActivity. Then click Finish.


After you click Finish, the project will be created and ready to build and run.

Congratulations. Your first project is complete.  Now we will try build and run this project.