Tuesday, August 24, 2010

Android On The Move

I like to keep my personal development environments on a USB drive, because i spend a lot of time on computers other than my own (mostly because of business trips).

So I felt the need to create an Android portable environment.
You can't build this environment on-the-fly, that is, without an initial installation. Most software will be 'stolen' from their original locations.

Sadly, i still only work on Windows (to lazy to spend more time on Linux), so i probably won't be able to help if you need to do the same on Linux (but probably it's not that different from what I did).

So here are the steps I managed so far:

1 - JDK
I'm using jdk1.6.0_20 (the latest at the time). I've downloaded and copied the jdk1.6.0_20 folder to my USB drive. A copy will be enough, after a little configuration.

2 - Eclipse
I'm using 3.5 (Galileo). Also just needed a simply copy of the root folder to the USB drive.

3 - Android SDK
I'm using revisions 6 (for Eclair) and 7 (for Froyo). You should download all the targets necessary before copying the folders. Then, you'll need to copy the root folder (android-sdk-windows) to your USB drive.

4 - AVD (Emulators)
To debug we need an emulator that will run our app. Unfortunately, it needs to be created beforehand on a fixed environment. So, all we have do is to copy the *.avd folder to our .android/avd folder.
AVD uses .ini files to configure target platform and installation path. As this has to be a full path and can't have shell variables, I chose to reconfigure that path in the batch file used to start-up eclipse.

5 - Batch file
To boot the environment we need to indicate to eclipse where to find the virtual machine and the sdk tools. So I start my environment with this script:

REM Updates AVD path config
type "%CD%\.android\avd\[sample].ini" | find /v "path=" > "%CD%\.android\avd\[sample].tmp"
copy /y "%CD%\.android\avd\[sample].tmp" "%CD%\.android\avd\[sample].ini"
echo path=%CD%\.android\avd\[sample].avd>>"%CD%\.android\avd\[sample].ini"
del "%CD%\.android\avd\[sample].tmp"

REM Defines Android home directory (defaults to the users' home directory)

REM Defines path to swt.jar (not sure if necessary)
SET ANDROID_SWT=%CD%\android-sdk-windows\tools\lib\x86

REM -data "." defines the workspace path to load
REM -vm defines the path to the virtual machine
.\eclipseJava\eclipse.exe -data "." -vm".\jdk1.6.0_20\bin\javaw"

This should be enough to allow you to take your Android developments everywere.

No comments:

Post a Comment