Tuesday, February 7, 2012

How to start developing Android apps on Fedora 16 (Linux)

Hello folks!

Damn, it's been a while since my last post. And after reading it again, I realised I didn't finish any of those things I said I would. Aaah. Procrastination. One does not simply make lists of what one wants done and then do those things.

Anyway, back to the topic at hand. The one you're probably here for: Getting Android development working in Linux distributions isn't as easy as it is for Windows or OSX. But I can give you a step-by-step tutorial about how to get started. Let's begin, shall we?
For the record, I have done all this on a fresh Fedora 16 (64bit - gnome3.2) installation.

Downloading some thangs
And here it is, the first and foremost advantage of development on Linux. apt-get and yum!
We need a few things to get started:
  1. Eclipse (+ any plugins you want if you want to use it for more than Android development.)
    It's a great IDE for lots of languages, even has LaTeX support and more!
  2. Get Java. Chances are you need to get OpenJDK instead of Oracle's. I used the stock Java libraries and stuff in Fedora's repositories and it does the trick.
  3. Download the Android SDK.
    Find it on Google, bro.
  4. Since my installation is 64-bit, and the Android thingies aren't, you need some 32bit stuff:
    sudo yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686
    If you have a Debian-based Linux distribution, just use apt-get (or Fedora).
Start installing like a boss
So, you've got the needed tools. Now it's just a question of getting them to play along:
  1. Extract the Android SDK and put it some place where you got permissions.
    (I put it in my home directory)
  2. Install the SDK. You need to do this by running: android-sdk-linux/tools/android
    It will ask you what API levels you want, just make sure to get at least 2.3.3. With that version you currently (as of February 2th, 2012) will support about 60% of the Android population.
  3. Start Eclipse, go to Help->Install New Software
    Just to be sure, press the Available Software Sites and make sure that the latest release of Eclipse is checked. At this time, it's http://download.eclipse.org/releases/helios
    Add a source, with https://dl-ssl.google.com/android/eclipse/ as location.
    Select it, and install the Development Tools it offers.
  4. It will also ask where your Android SDK is located. Just point it to the android-sdk-linux folder.
Done. Start coding.

Extra for being really pro
So, you've dabbled a bit in Android development, but the emulator is rather slow. Fear not, let's start debugging and running your apps on your own phone instead of that emulator!
  1. Make sure your application is flagged as debuggable. This is done in your manifest file.
    Add android:debuggable="true" to the element.
  2. Set your device to allow the installation of Non-Market applications. (Unknown Sources)
  3. Set your device to enable USB Debugging.
  4. Set up your system to enable the debugging. (With Windows, you would need drivers, LOL)
    Log in as root and create the following file:
    /etc/udev/rules.d/51-android.rules
    Edit this file and fill it with the following:
    SUBSYSTEM=="usb", ATTR{idVendor}=="04E8", MODE="0666", GROUP="plugdev"
  5. Notice the "04E8". I used this specific string because it stands for a Samsung Device.
    I have a Galaxy S2 so that would obviously be the right thing to do.
    However, chances are you got a phone of a different brand. Consult the following table:

    CompanyUSB Vendor ID
    Acer0502
    ASUS0B05
    Dell413C
    Foxconn0489
    Fujitsu04C5
    Fujitsu Toshiba04C5
    Garmin-Asus091E
    Google18D1
    Hisense109B
    HTC0BB4
    Huawei12D1
    K-Touch24E3
    KT Tech2116
    Kyocera0482
    Lenevo17EF
    LG1004
    Motorola22B8
    NEC0409
    Nook2080
    Nvidia0955
    OTGV2257
    Pantech10A9
    Pegatron1D4D
    Philips0471
    PMC-Sierra04DA
    Qualcomm05C6
    SK Telesys1F53
    Samsung04E8
    Sharp04DD
    Sony Ericsson0FCE
    Teleepoch2340
    Toshiba0930
    ZTE19D2
  6. Finish by a chmod:
    chmod a+r /etc/udev/rules.d/51-android.rules
Have Fun.
That's all to it. Just create a new application using the wizard now installed in Eclipse. You'll have a Hello World app which will be perfect for testing if your IDE is working.

And now, my Padawan, start coding some awesome Android apps.

Greets,

Thomas

Inspired by and got some help from:

1 comment:

  1. Good day!

    I hope you can post strategies and examples on how to program android using Eclipse.

    It would be very helpful for me, specially that I am a IT student.

    Thank You!:)

    DevelopingAndroid Apps

    ReplyDelete