2012年2月28日 星期二

設定 Ubuntu Oneiric 上的 Android build 環境

0. Firstly, test system architecture by
  dpkg --print-architecture
   On my notebook, it showed "amd64"

1. Installing Java JDK and JRE
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-plugin sun-java6-jre
sudo update-alternatives --config java
--------------------------------------------
Selection Path 優先級 Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode

Press enter to keep the current choice[*], or type selection number: 2
--------------------------------------------

2. Install build tools(Reference to http://source.android.com/source/initializing.html)
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs --fix-missing
---- ia32-libs
sudo apt-get install x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev --fix-missing
---- lib32readline5-dev
sudo apt-get install libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown --fix-missing
---- mingw32 python-markdown
sudo apt-get install libxml2-utils xsltproc
sudo apt-get install libx11-dev:i386


** Note 1:
While doing installation packages, the "universe" pool was disappeared while lot of items are required to be there.
The answer is switching to other server, I choose the server in China ubuntu.cn99.com
==> Use the 軟體來源 to do the switching.
==> This can fix the ia32-lins, mingw32, g++-4.4-multilib gcc-4.4-multilib
** Note 2:
Another package lib32readline5-dev was changed to lib32readline-gplv2-dev, use it instead.

3. Switch to gcc 4.4 :
After installing all required packages, we need to note that since some syntax issue in android framework, using gcc/g++ 4.6 will be failed. We need to change back to 4.4
Step 1: Install gcc 4.4 packages
sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib
Step 2: Change gcc 4.4 by default
$sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4 --slave /usr/bin/gcov gcov /usr/bin/g++-4.4

$sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 --slave /usr/bin/gcov gcov /usr/bin/g++-4.6

$sudo update-alternatives --config gcc

Use gcc 4.4 by default

Step 3: Change g++ 4.4 by default
chenhj@chenhj-MacBookPro:/etc/alternatives$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 50
[sudo] password for chenhj:
update-alternatives: using /usr/bin/g++-4.4 to provide /usr/bin/g++ (g++) in auto mode.
chenhj@chenhj-MacBookPro:/etc/alternatives$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 40
chenhj@chenhj-MacBookPro:/etc/alternatives$ sudo update-alternatives --config g++
There are 2 choices for the alternative g++ (providing /usr/bin/g++).

Selection Path 優先級 Status
------------------------------------------------------------
* 0 /usr/bin/g++-4.4 50 auto mode
1 /usr/bin/g++-4.4 50 manual mode
2 /usr/bin/g++-4.6 40 manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/g++-4.4 to provide /usr/bin/g++ (g++) in manual mode.

沒有留言: