Saturday, September 27, 2008

[How-to] Install Android SDK on Asus eeepc Linux

Asus eeepc comes with xandros Debian Linux version but does not have development tools. This guide shows you how to setup the development tools for Android SDK.

Part (A) You need to add the debian package source and install the compiling tools and JDK from Sun in eee pc Linux

(1) Launch Terminal (Ctrl-Alt-T)

(2) edit the file/etc/apt/sources.list
sudo vi /etc/apt/sources.list

and add this line to the end of the file "sources.list"
deb http://http.us.debian.org/debian/ stable main

(3) Run these commands in Terminal to install building tools

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential ant



(4) Download JDK from Sun
(Latest Release)
http://java.sun.com/javase/downloads/index.jsp

The current version of JDK is
Java SE Development Kit 6u7
Download the Linux version and the file without rpm. That is

jdk-6u7-linux-i586.bin

(5) Run these commands in Terminal to install JDK


chmod +x jdk-6u7-linux-i586.bin
./jdk-6u7-linux-i586.bin

#then follow the install instructions and answer yes and then a directory jdk1.6.0_07 will be created

sudo mv jdk1.6.0_07 /usr/
cd /usr/bin
sudo ln -sf /usr/jdk1.6.0_07/bin/java
sudo ln -sf /usr/jdk1.6.0_07/bin/javac
sudo ln -sf /usr/jdk1.6.0_07/bin/jar


Part (B) Download and Install Android SDK

(1) Download the Android SDK
http://code.google.com/android/download.html

download the Linux version, the current version is
Linux (i386) android-sdk-linux_x86-1.0_r1.zip

(2) unzip and install the android SDK say to /usr/

unzip android-sdk-linux_x86-1.0_r1.zip
sudo mv android-sdk-linux_x86-1.0_r1 /usr/


(3) edit ~/.bash_profile
vi ~/.bash_profile
change
PATH=~/bin:"${PATH}"
to
PATH=~/bin:/usr/android-sdk-linux_x86-1.0_r1/tools:"${PATH}"

(4) Test run Android emulator

starting emulator in portrait mode will be out of view in eeepc, so we need to run it in landscape mode. Moreover the sound does not work.
To start the emuator for the first time, use these commands in Terminal

Assume, Android SDK is installed in /usr and android data will be kept at ~/androiddata


export PATH=${PATH}:/usr/android-sdk-linux_x86-1.0_r1/tools
mkdir -p ~/androiddata
emulator -datadir ~/androiddata -noaudio -skin HVGA-L


or, alternatively, if you have to run the emulator in portrait mode, you need to scale it say by 0.6

emulator -datadir ~/androiddata -noaudio -scale 0.6



Please be patient for the Emulator for the first time as it takes very long to create the data on first installation


Part (C) Test building HelloActivity from the sample code

(1) If you have installed the Andriod SDK and started the emulator for the first time, it is better to reboot the computer first and then start the emulator again.

(2) Create the Projects directory say
mkdir -p ~/Projects

(3) start emulator in Terminal
emulator -noaudio -skin HVGA-L &

(4) copy the HelloActivity from sample of SDK to Projects directory
cp -r /usr/android-sdk-linux_x86-1.0_r1/samples/HelloActivity ~/Projects/

(5) Use activityCreator to create the build file
activitycreator --out ~/Projects/HelloActivity com.example.android.helloactivity

(6) Build the HelloActivity project
cd ~/Projects/
ant


(7) Install the HelloActivity project to emulator
cd ~/Projects/
ant install


Remember, you must start the emulator before installing binary

(8) Then you can test the installed program HelloActivity in the emulator
To uninstall the program do this in Terminal
cd ~/Projects/
ant uninstall


If you need an integrated development environment, use Eclipse and install the plug-ins as described in the Android download site.

If you amend some codes in the Project and want to reinstall use

cd ~/Projects/
ant reinstall



For Mac OS X installation, just skip the Part (A) of this guide and follow similar procedure in other parts, as Mac OS X has these building tools / JDK already installed.

For other sample projects from SDK the activityCreate scripts are
cp -r /usr/android-sdk-linux_x86-1.0_r1/samples/LunarLander ~/Projects/
activitycreator --out ~/Projects/LunarLander com.example.android.lunarlander
cd ~/Projects/LunarLander
ant install

cp -r /usr/android-sdk-linux_x86-1.0_r1/samples/NotePad ~/Projects/
activitycreator --out ~/Projects/NotePad com.example.android.notepad
cd ~/Projects/NotePad
ant install

cp -r /usr/android-sdk-linux_x86-1.0_r1/samples/Snake ~/Projects/
activitycreator --out ~/Projects/Snake com.example.android.snake
cd ~/Projects/Snake
ant install


Enjoy.

9 comments:

rzr said...

http://digg.com/linux_unix/Android_on_EeePC?t=23358958#c23358958

Why not installing android directly on the eeepc701 ? check previous url for video tutorial

Troy Borja said...

Hi,

Have you tried the new Android 1.5 SDK? I was able to run Android 1.0 on Eclipse 3.4 on my eeepc 900 but now having problems with Version 1.5 of the Android SDK. The problem is with the new project wizard for Android not finding the target SDK.

javacom said...

If you use Android SDK 1.5, you should set the path of your sdk in the Update your Eclipse SDK Preferences after you installed the ADT

see here
http://developer.android.com/sdk/1.5_r2/upgrading.html#UpdateAdt

And then create the AVD

see here
http://developer.android.com/guide/developing/eclipse-adt.html

javacom said...

If you don't use Eclipse, you should use

android update project in SDK 1.5
instead of ActivityCreator

Moreover, you need to create the AVD first

see here
http://developer.android.com/guide/developing/other-ide.html

Shanjaq said...

Thank you for your help! Instructions worked pretty well on Debian Lenny(not without the usual "invisible brick wall" antics encountered by a Linux newb..)

I didn't have much room to spare on the internal SSD so I dumped the ~400mb SDK on a removable SD card. I figured since the SDK is read-only in most cases it would benefit from the improved access time of SD media while minimizing cumulative damage caused by writes.

Shanjaq said...

Is it possible to install Eclipse to the SD card removable media as well? that's about 400mb with dependencies, and my 2gb SD card has 1.6gb left after the SDK was placed, so I'd be happy to create a complete "Android Development Disk" out of this SD Card!

I've tried downloading all of the debs and installing like so:
mkdir -p /media/disk/archives/partial
apt-get -d -o dir::cache=/media/disk install eclipse
cd /media/disk/archives
dpkg -i --instdir=/media/disk/eclipse eclipse_3.2.2-6.1_i386.deb

but its having troubles with the pre-install scripts(among other things...)


Has anyone attempted to install such a program to a removable disk?

javacom said...

sdcard is slow.

Anonymous said...

Slow or not, some have no choice.

Do you know how to install Eclipse to an SD card?

javacom said...

Just download of zip file from eclipse and unzip to a directory in your sdcard.