Skip to content

Setup Android environment from source

Amr Aboelela edited this page Mar 17, 2015 · 1 revision

Parent page: Android

We need to build it from the source then we can slowly change the source to what we need. Also the source will give us an insight of how things work and what libs they use internally. It is also amazing that they also use Ubuntu and lots of the packages they install, we also install, like mesa and x11 packages.

Building up the environment for Android Source Code:

  1. Creating VBox Machine:

    • Create new VBox machine:
      • Name:
      • System: Linux
      • Type: Ubuntu (64bit)
      • RAM: 2048 GB (assign more if possible)
      • HDD: 10GB (dynamic) - used for Ubuntu installation.
    • Select the created machine, go to settings
      • Add another network interface attached to Host-only adapter for ssh.
      • Add another HDD 45GB (dynamic) - used as workspace.
      • Add another processer under System > Processor to speed up the machine (in case of multi-core host machine).
  2. Ubuntu installation:

    • Download Ubuntu Desktop 12.04. [http://www.ubuntu.com/download]
    • Start the VBox machine and mount the downloaded Ubuntu iso.
    • Proceed with the installation process, make sure of using the 10GB HDD for installation.
  3. Android Source Environment:

$ chmod +x jdk-6u45-linux-x64.bin
$ sudo ./jdk-6u45-linux-x64.bin
$ sudo mv jdk1.6.0_45 /usr/lib/jvm/
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 1
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_45/bin/javaws 1
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config javaws
* Installing required packages (Ubuntu 12.04) in this "link":http://source.android.com/source/initializing.html
  1. Download source code in this "link": [http://source.android.com/source/downloading.html] Note: init for master branch.
  2. Building source code:
    • Under the source directory run the following in terminal
$ source build/envsetup.sh
$ lunch full-eng
* Error Mitigation:
ERROR: “_FORTIFY_SOURCE” redefined [-Werror]
FIX:
The error can be fixed by changing the HOST_GLOBAL_CFLAGS on line 56 in build/core/combo/HOST_linux-x86.mk from
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 
to
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
ERROR:  external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive] 
FIX: 
in external/libpp/format_output.h b/libpp/format_output.h 
 -               mutable counts_t & counts; 
 +               counts_t & counts; 
ERROR:  frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable] 
FIX: 
in android/ics/frameworks/compile/slang/Android.mk 
-local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror 
+local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-paramete
ERROR:  external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
FIX: 
in external/gtest/internal/gtest-param-util.h 
 #include  
+#include  
 #include 
ERROR: undefined reference to `pthread_....
FIX:
add "LOCAL_LDLIBS := -lpthread -ldl" in external/llvm/llvm-host-build.mk
* Run make command
$ make -j4

##Child page

##External links

####Fixing common error links

Clone this wiki locally