Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Jan 21, 2013

Compile Android 2.3.3 in Slackware 14

I. Introduction:
Recently I decided to change my linux distro from ubuntu to slackware. The installation process is nice and smooth. After I install slackware, I decided to download the android 2.3.3 source and compile myself. I have done it before in ubuntu 10.04, so I told to myself how hard could it be. However I was wrong, compiling android in slackware 14 is incredibly annoying. Most of the problems are caused by gcc and perl version mismatch. Some people might say, just downgrade/upgrade your gcc/perl version and it should be fine. I know that, but changing gcc/perl version in your system might cause some problems and I don't want to take that risk. (btw, recompile gcc is very time consuming in my computer. Hardware sucks) 
Because the above reason, I decide to compile the android 2.3.3 without downgrade any tools and also to write the whole process down to remind myself how I do it.

II. Environment:

  • Linux Distro : Slackware 14 x86_64( with multilib support )
  • gcc version : 4.7.1
  • make version : 3.82
  • perl version : 5.16
  • git version : 1.71
  • python version : 2.73

Just a clean install of slackware 14.
As for multilib support just check out Alien BOB wiki and follow the instructions that wiki mentioned. 
P.S you should at least have >2GB of RAM or the building process may failed. 


III. Compiling Steps:
This post is mostly focus on how to solve the version mismatch problems; therefore, I will not cover how I setup the build environment in this post. (Most libraries that required to build android are already installed by the Slackware 14 clean install)
After you follow the ASOP instructions and install all the necessary packages, it is time to type make command. (I highly recommend that use 'make -j1' instead of 'make -j8' )

1. GCC version mismatch:
The following is an example of how this kind of error message look like and the general solutions of how to solve this kind of problems. Figure 1 shows how this kind of error message looks like. There are two ways to solve this kind of problem. 
The first one is add "this->" in front of all the variables that appear in the error message. However, in the entire building process, you will be very annoying adding this pointer in front of all the errors.
The second method is to add  "-fpermissive" flag in the makefile. More precisely add "-fpermissive" to LOCAL_CFLAGS in Android.mk. This method is more reasonable. 
During the whole building process, there are several Android.mk files that need to be modified (adding "-fpermissive" flag)


frameworks/base/tools/aapt/Android.mk
frameworks/base/libs/utils/Android.mk
external/srec/tools/grxmlcompile/Android.mk
external/srec/tools/thirdparty/OpenFst/fst/lib/Android.mk
external/srec/tools/make_cfst/Android.mk
external/v8/Android.mksnapshot.mk

 
[figure 1] gcc version mismatch error message
[Figure 2] Add "-fpermissive" after the LOCAL_CFLAGS in the Android.mk

2. perl Switch module problem:
Switch.pm is deprecated in perl 5.16, therefore the solution is simple, patch the "external/webkit/WebCore/dom/make_names.pl". Figure 4,5,6 show some modification of this file. 
[Figure 3] Can't locate Switch.pm
[Figure 4] comment use Switch
[Figure 5] use if else instead of switch case


[Figure 6] delete the "-P" flag from preprocessor
IV. Conclusion:
After the above steps, the building process should be fine and you can see the image file in the out directory.
I also make a diff file which you can download from here: http://pastebin.com/RCfB5irk
Just download the file and type:
patch -p1 < patch_file_name.patch
Enjoy :)

Apr 20, 2011

building the android adt for eclipse

After building the android source code and the sdk. I tried to build the adt as well.
But remember when you make adt, android will delete the .sdk and the .img which generated from android source code. (I took a lot of time to make the image files T T )
Therefore, my advice is backup those file before building the android adt.

OS: ubuntu 10.10
java version: sun-jdk1.5

Ok, now this is how I built my android adt.
1. Download  eclipse from here. (I prefer Download manually. When I use apt-get install eclipse, the building process failed.)
P.S I prefer the RAP and RCP version (since the package is smaller).

2. After downloading, extract the file to any directory you want.
   for example: ~/eclipse

3. set the environment variable ECLIPSE_HOME.
    export ECLIPSE_HOME=${the directory you extract your eclipse}

4.the final step is to make the adt using the script contain in the source code.
    ${android home}/tools/eclipse/scripts/build_server.sh ${destination-directory}
    
P.S the build_server.sh script may be contains in different folder depend on which version of source code you download
           ${android home} is where your android source code is
           ${destination-directory} is where you want to put your adt zip file.


After all these steps, you can see a zip file in your destination folder.


reference website: Build android device tool for eclipse

Apr 18, 2011

building the android sdk

After compiling the android source, It's time to compile the sdk.
Remember before start compiling the sdk, you need to use the sun jdk 1.5.
use this command: update-alternatives --config java 
to switch to jdk5.
However, when I'm compiling the sdk when follow the above steps, there are still error.
My solution is:
1. use lunch sdk-eng before make sdk(if the error still occur)
2. remove all the java sdk in my ubuntu such as openjdk and sun-java1.6.jdk(except jdk5)

And after these two steps, I successfully finished compiling the sdk
you can find the jdk in ~/out/host/${your_machine}/sdk
here is the layout:
drwxr-x--- 3 user user      4096 2011-04-18 10:11 .
drwxr-xr-x 9 user user      4096 2011-04-18 10:10 ..
drwxrwx--- 7 user user      4096 2011-04-18 10:10 android-sdk_eng.user_linux-x86
-rw-r--r-- 1 user user 172889941 2011-04-18 10:11 android-sdk_eng.user_linux-x86.zip
-rw-r--r-- 1 user user    648232 2011-04-18 10:11 sdk_deps.mk


steps review:
                     sudo update-alternatives --config java(change to jdk5)
                     lunch sdk-eng
                     make sdk

Before building the android source

What I forgot to mention in the previous is that the environment setting.
Before we start downloading and compiling the android source code, there are
some important stuff we need to do first.
1.according to the website, we need to download the jdk6 for Gingerbread and newer. And jdk5 for froyo or older.

  The following is how to do this.
   add deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
          deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
   in your /etc/apt/source.list
  
   and sudo apt-get update
          sudo apt-get install sun-java5-jdk(for jdk5)
  
after that the sun java jdk5 is installed.
you can use : update-alternatives --config java 
to change which version you want.


2. the rest of the package is just like the website says. follow those steps and you can start download and compile your android.

compiling android source code

Yesterday, I finally finished compiling the android source code. It took me the whole afternoon to accomplish this job.
The following is how it work.
My environment is: ubuntu 10.10 netbook edition. 

1.download the android source code.(Tooks me lots of time. 5GB source code)
    this step is referenced from the android official website.
2.compile the android source code
    the official website has it all. However, there are some detail that the website doesn't mentioned.
     when compiling the source code, I met two problems.
      a.the first problem happened when compiling the qemu,
         and the solution is install some extra packages.
         sudo apt-get install xllproto-core-dev (provides Xatom.h)
         sudo apt-get install libxll-dev (provides Xlib.h)
      referenced website: Issue 15
    
     b.another problem is when compiling the adb,
        Error message is like: /usr/bin/ld: cannot find -lncurses
        solution is install an extra package.
        sudo apt-get install libncurses5-dev
     reference website: problem compiling adb....

After these problems, everything works really fine.

And after compile is finished, u will see a directory called "out" in you android root directory.



Labels