Updated 2012-06-28 The original article was written for and tested on fedora 15. This is the revised version for Fedora 17.
Here are the steps I followed in order to start developing android applications on my Fedora 15 x86_64 box. The actual list is a collection from various sources that I am listing at the end of this post put together in a start-to-finsh
manner, so we can start developing almost right away.
Step 1: Install the Sun Java
Download the appropriate rpm for your architecture by visiting the Oracle Java SE Downloads site. Follow this link. Select the latest Java SE 6 Update and download it on your machine.
After download is complete, open a terminal window, cd to your downloads directory and enter the following command :
[thanassis@nb-thanassis Downloads]$ sudo sh jdk-6u27-linux-x64-rpm.bin
Step 2: Make Sun Java the default Java for your machine
Using the alternatives command -- thanks to Mauriat Miranda -- you may change the default java used by your system like this :
sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/default/bin/java 20000
To test, try the following:
[thanassis@nb-thanassis Downloads]$ java -version java version "1.6.0_27" Java(TM) SE Runtime Environment (build 1.6.0_27-b07) Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
Step 3: Download and install the Android SDK core support
Start from this page here:
Download the latest android SDK and unpack it in a directory of your choosing. We will need to modify our path variable based on that, so I recommend that you change the base name from android-sdk-linux_x86
to AndrodSDK
and move it to /opt
.
Next, edit your .bashrc file and modify your path variable to include AndroidSDK/tools and AndroidSDK/platform-tools. The corresponding PATH statement should more or less look like this:
export PATH=$PATH:/opt/AndroidSDK/platform-tools:/opt/AndroidSDK/tools
To start the android emulator on a 64 bit machine we need some additional 32bit packages. These can be installed using the command
sudo yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686
Step 4: Start the android application, download the SDK files and build a virtual device
Run command /opt/AndroidSDK/tools/android
. From the available packages select the SDK version and the documentation for the versions you are planning to work with. Click the install selected button on the right and then accept the license terms and complete the installation of the selected software.
Next create an AVD device. Using the Android SDK manager, click on the Tools menu and then select the Manage AVDs option. Click the New button from the window that pop up and fill in information about the new device
Click create AVD to create your device. After device creation is complete, close the android application and log out and in again to make the paths work.
When you are back in, start the android application directly from a terminal window and start your new device just to be 100% sure that everything works fine.
Step 5: Install eclipse and the ADT plug-in
I do not recommend installing eclipse from the fedora repositories. I have experienced many issues -- especially after updates -- so in my view it is much simpler to download the entire eclipse IDE directly form the downloads page of the eclipse web site, unpack it in a directory of your choosing and finally move it to /opt.
tar -zxvf eclipse-java-juno-linux-gtk-x86_64.tar.gz sudo mv eclipse /opt/
After eclipse is installed on our Linux box we need to install the android development plug-in. This is done by selecting Help → Install new software from the eclipse main window menu. Click the Available software sites link and make sure that the entry http://download.eclipse.org/releases/juno is enabled. Otherwise install it by clicking the add button and create a new software repository like this:
The images shown here are from the previous version of eclipse (Helios). New version images are similar with slight aesthetic differences
While you are there click the add button again, in order to create the android plug in repository. The repo URL is https://dl-ssl.google.com/android/eclipse/ and the add repository window should be filled like this:Make sure that both repositories are enabled, by activating the check box on the right and press Ok to dismiss the dialog. Now we are ready to perform the actual plug-in installation. Select the ADT plug-in on the Work with field and then check all available software. Click Next accept the license agreement and after download and install is over restart eclipse..
That should be enough to get you started.
Step 6: Create the Hello world application
At this point we shall create a simple hello world application and deploy it first on the android emulator and next to an actual android device connected via USB. Start the eclipse IDE, click File → New → Project and then select Android project from the dialog that pops up. Click next and fill in the Project name and package name fields wth the values HelloWorld
and org.example.hello
respectively. Click Finish to create the project.
Just to spice up things a bit more, open the res/values/strings.xml
file and change the value of the hello string to Hello Android from Fedora
. Save the file and run the application; the android emulator will eventually load and the application will be deployed and run on it, so you 'll probably end up seeing something like this:
Step 7: Connect your android device to Linux.
Our last job will be to connect an actual android device to our Linux box and deploy our HelloWorld
application onto that device.
Remember that before we connect the actual device we need to change the following settings on the device:
- Menu Settings → Applications, enable Unknown (or Untrusted) sources.
- Menu Settings → Applications → Development, enable USB debugging.
The last part comes directly from Peter Kirns blog post. We need to configure Fedora’s udev rules to support our device in debugging mode.
As the super user create or edit the file /etc/udev/rules.d/51-android.rules
and place the following line in it:
SUBSYSTEM=="usb",0bb4",SYMLINK+="android_adb",MODE="0666"
The SYSFS{idVendor}=="xxxx"
entry must be filled with the USB Vendor ID of your device manufacturer. (the example here assumes you are using HTC). The list of all devices is available from Google's Using Hardware Devices Android Developer's page via this link. There is one last thing though: Vendor Ids must be typed in small letters, although Google's table lists them in capital.
You can even set up your environment to allow connections to multiple devices by adding more than one line in the 51-android.rules
file.
As an example have a look at my setup that allows me to connect to a Samsung, a Sony Ericson and an HTC device :
[athanassios@hades rules.d]$ cat 51-android.rules SUBSYSTEM=="usb",SYSFS{idVendor}=="04e8",SYMLINK+="android_adb",MODE="0666" SUBSYSTEM=="usb",SYSFS{idVendor}=="0fce",SYMLINK+="android_adb",MODE="0666" SUBSYSTEM=="usb",SYSFS{idVendor}=="0bb4",SYMLINK+="android_adb",MODE="0666"Finally, reload rules by using:
udevadm control --reload-rules
Connect your device. In case it prompts for a connection mode specify that it should act as a USB storage unit (disk drive).
Testing connection can be done by using:
[thanassis@nb-thanassis ~]$ adb devices * daemon not running. starting it now on port 5037 * * daemon started successfully * List of devices attached SH16ERT01652 device
Start eclipse and run your hello project again. This time the ADT plugin will detect your device deploy your application onto it and you will see the hello world message right onto your android's screen.
Notes
In order to compile this list I used the following links. Thanks and credits go to the original authors.
1 comment :
Thank you so much for this tutorial, it helped me a lot!
I've installed Eclipse on my centos 6.3 OS and I couldn't run the emulator untill I read your instructions.
Post a Comment