Building Android on Gentoo

Ok, it is generally best practice to use Ubuntu  for building android but if you are a Gentoo fan and don’t want to mess with a vm you’ll have to bypass some bumps first.

So let’s start. Firstly you need sun-jdk6. icedtea-jdk won’t do the trick. So let’s get sun-jdk6 firstly. I’m going to just pass the commands you need and it should be self explanatory if you know what you are doing.

Download java and put it at /usr/portage/distfiles/

su-
cd /usr/portage/distfiles
wget http://uni-smr.ac.ru/archive/dev/java/SDKs/sun/j2se/6/jdk-6u45-linux-x64.bin

Then copy paste the exact same lines as below to auto-accept all licenses.


cat >> /etc/make.conf <<END
ACCEPT_LICENSE="*"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --autounmask=n"
END

Then let’s unmask sun-jdk. It’s masked for security reason but we really need this. So edit  package.unmask with your favorite editor ( vi /etc/portage/package.unmask ) and add at the bottom


=dev-java/sun-jdk-1.6.0.45

Ok we’re ready let’s emerge


emerge dev-java/sun-jdk

After you’ve done select the appropriate package by issuing


java-config --set-system-vm sun-jdk-1.6

Afterwards let’s emerge all the packages we need to compile android.


emerge git app-crypt/gnupg flex bison gperf libsdl wxGTK squashfs-tools curl ncurses zlib schedtool perl-Switch zip unzip emul-linux-x86-baselibs emul-linux-x86-compat emul-linux-x86-cpplibs

You should be all done expect one last thing. repo sync etc. and before you start your build goto core/config.mk and comment out the following lines.


+#ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
+#$(error Error: could not find jdk tools.jar, please install JDK6, \
+#    which you can download from <a href="http://java.sun.com" target="_blank">java.sun.com</a>)
+#endif

You are good to go! Happy android building!

#android, #building, #endif, #gentoo, #ifeq, #requires_openjdk, #sun-jdk

Android Studio Installation: Error, “failed to find java version for ‘C:\windows\system32\java.exe”

So this is quite simple to solve.

Goto http://www.oracle.com/technetwork/java/javase/downloads/index.html and download the latest jdk for your architecture x32 or x64.

Install as usual and then goto Control Panel -> “Advanced System Settings”

Click on the “Enviroment Variables” and under “System Variables” click “New..”

Then create a new entry with Variable Name: “JAVA_HOME” and Variable Value: “C:\Program Files\Java\jdk1.7.0_21” (this differs according to the version and system).

Save and restart android studio installation and it should identify the correct pat.

#android, #android-studio, #development, #error, #failed, #java

Git: Cherry-picking from another repository

Quite often when working with an android kernel there would be some nifty commits you’d wish to add to your local repo. So here is the way to do it.

In my case i am working on the Huawei kernel for G300 which involves the msm7627a chipset. So let’s patch it a bit with some commits from Code Aurora Forum (CAF).

Firstly let’s fetch our project locally

git clone https://github.com/ezeteze/android_kernel_huawei_u8815 g300-kernel

Okey now let’s add our remote branch and fetch.

git remote add msm  git://codeaurora.org/kernel/msm.git

git fetch

Cool! Now git branch -a should show your branches and all the remote tracking branches. You are now ready! You can either cherry-pick your commits or if you are brave enough do a full merge, which will probably result in ^n conflicts!

Let’s try out a cherry-pick

akis@localhost:~/kernel/huawei/u8815$ git cherry-pick 4e17bc5b7846448344c262c89ce769f756864b62
[detached HEAD 7ce9f8c] msm: qdsp6v2: Reduce the step size of soft volume and soft pause.
Author: Deepa Madiregama <dmadireg@codeaurora.org>
2 files changed, 8 insertions(+), 2 deletions(-)

Success! Happy cherry-picking! 🙂

#android, #cherry-pick, #cherry-picking, #code-aurora-forum, #github, #kernel, #msm

[Android] Add init.d support to your ROM.

1) Make sure you have busybox on your xbin folder.

2) Extract boot.img and ramdisk and place this lines on the bottom of init.rc

service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
   disabled
   oneshot

3)Repack and you are done! You can now add any scripts you like to run at boot at /etc/init.d/ folder!

#android, #cyanogenmod, #d-computer, #init, #technology

[Android] Unpack and edit boot.img

1) Get abootimg:

sudo aptitude install abootimg

2)Extract boot.img

abootimg -x boot.img

3)Extract initrd.img to initrdorg folder

mkd initrdorg
cp initrd.img initrdorg
cd initrdorg
gunzip -c ../initrd.img | cpio -i

4) Edit and repack
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
cp newramdisk.cpio.gz ../
cd ..
abootimg -u boot.img -r newramdisk.cpio.gz

You are done!
Tip: Remember to delete any *~ files gedit might have create before repacking!

#android, #boot-img, #computer, #edit, #initrd-img, #technology, #unpack

/usr/bin/ld: cannot find -lz when compiling android source

You are probably on a 64bit system. Just do:

sudo apt-get install lib32z1-dev

#android, #cyanogenmod