Building Android SDK on Fedora 20

See Building Android Tools and Fedora Android Setup for reference. Commands like yum have to be sudo’ed or run by root, all other commands should be run by an ordinary user.

Make sure you have about 30-100 Gigs HD space available (depending on on what you build).

Since fedora 20 starts out with kernel 3.11, I updated to 3.13 (probably not necessary, but I really like 3.13). Reboot if you updated your kernel:

yum update

Install android emulator 32 bit packages:

yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686

Install other needed packages:

yum install gcc gcc-c++ gperf flex bison glibc-devel.{x86_64,i686} zlib-devel.{x86_64,i686} ncurses-devel.i686 libsx-devel readline-devel.i686 perl-Switch git gpg schedtool

Make sure you have javac:

yum install java-1.7.0-openjdk-devel.x86_64

Alternatively, you can install all required packages with one command:

yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 \
ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686 gcc gcc-c++ gperf \
flex bison glibc-devel.{x86_64,i686} zlib-devel.{x86_64,i686} ncurses-devel.i686 libsx-devel \
readline-devel.i686 perl-Switch git gpg java-1.7.0-openjdk-devel.x86_64 schedtool

Install repo:

mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Make sure repo works (on my freshly installed fedora 20, ~/bin was already in the path).

Check out sources. repo sync can take a long time. Another example for -g would be -g all,-notdefault,-device,-mips,-eclipse,-darwin to omit builds you probably don’t need. You might also adapt the -b flag for another android version (e.g. -b android-sdk-4.4.2_r1), but branches other than master might not support building on Open JDK 7. Also append --config-name if you want to change your git developer name.

mkdir ~/android
cd ~/android
repo init -u https://android.googlesource.com/platform/manifest -g all,-notdefault
repo sync

Create the cache:

echo "export USE_CCACHE=1" >> ~/.bashrc
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 25G

Use JDK 7:

echo "export EXPERIMENTAL_USE_JAVA7=true" >> ~/.bashrc
export EXPERIMENTAL_USE_JAVA7=true

Build (adjust make -jn for the number of cores / hardware threads in your machine). The code here juse uses the number of available CPUs. According to the Replicant SDK build instructions best results on fast hardware will come with -j9, -j16 and -j32:

. build/envsetup.sh
lunch sdk-eng
parallel_tasks=$(echo "$(grep 'processor' /proc/cpuinfo | wc -l ) + 1" | bc)
make -j$parallel_tasks sdk

Some output files are located at:

out/host/linux-x86/sdk/
out/host/linux-x86/bin/

Your SDK zip should be located here: out/host/linux-x86/sdk/android-sdk_eng.<username>_linux-x86.zip

Notes

If you’re only interested in adb and fastboot (e.g., for bootstrapping a cyanogen mod device build), then just make those:

make fastboot adb

On my machine the adb and fastboot didn’t work very well, but the ones from a Replicant SDK build did.

10 thoughts on “Building Android SDK on Fedora 20

  1. Dan I.

    Sorry to comment in the wrong place, but I noticed that iNethack is no longer in the App Store. Will it return, or is it gone for good? Thanks!

    Reply
    1. dirk Post author

      I won’t put it there again. It never was a comfortable fit (legally speaking) and I didn’t really maintain it since 1.3 so I let my developer license lapse. It was lots of fun and very exciting back in 2009 🙂

      Reply
  2. Robbie Gorman

    Apologies for also comment hijacking.

    A friend of mine (definitely not me) just bought an iPad mini, mainly for the purpose of playing Nethack HD.

    Out of curiosity, how much did he miss it by – a week, a month etc?

    Apparently, this guy is doubly upset since he’s travelling and can’t even put iNethack on his iPad until he gets home.. 😉

    Reply
    1. dirk Post author

      I think my license was due for renewal in January. Sorry about your friend, I can relate to not having synced something I would have dearly needed while traveling.

      Reply
  3. Robbie Gorman

    (Apologies again for comment hijacking)

    Dirk,

    My friend will definitely be comforted to know he missed it by a few months 😉

    He has some experience of being haunted by random coding from his past – he was previously an intensive Freelancer hacker until the cease and desists started being issued from MS and was frustrated for many years by people contacting him about old code. It is simultaneously flattering and irritating!

    Very good work on the ports, my friend will continue to enjoy them in small format 😉 I wish you good luck going forward.

    Best Regards,

    Robbie

    Reply
  4. Dan I.

    Is the code for iNethack on github the most current V1.3? Do you think someone with iOS development experience (not me, but a friend of mine) might be able to compile a usable copy of the game for private use? As you can see, I’m still very eager to play iNethack! If only I had gotten my iphone 3 months earlier!

    Reply
    1. dirk Post author

      The code contains patches after 1.3 never published, but I tagged every release so there’s also a commit for 1.3. I don’t know how easy it is to build now that xcode has added 3 or 4 major versions on top since then 🙂

      Reply
  5. dirk Post author

    Note: I might not be able to reply to comments (or even approve them) for the next couple of weeks.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax