[HOW TO] Android Build Environment on Ubuntu 12.04

Search This thread

AndroidUser00110001

Senior Member
Aug 16, 2011
3,432
5,739
NYC
So my desktop system died after many years and I just finished building my new system. I stopped cooking ROMs some time ago and it was time to setup my Android build environment again. Last time I did that Google's directions were pretty much straight forward and did not run into any issues. Can't say that for this time, AOSP site needs to update their instructions a bit. I made notes during the process and thought to share them in case anyone finds themselves in a spot like me.

Use this guide as you follow the instructions at the AOSP website and you should be fine. You can copy and paste all the terminal commands.

Initializing a Build Environment - Google's Instructions HERE

Python

Python 2.6 -- 2.7 - Install dependencies before installing Python
Code:
sudo apt-get install build-essential
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Download Python
Code:
cd ~/Downloads/
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz

Extract & Change Directory
Code:
tar -xvf Python-2.7.6.tgz
cd Python-2.7.6

Install
Code:
./configure
make
sudo make install

GNU Make 3.81 -- 3.82

Download GNU Make
Code:
cd ~/Downloads/
wget http://ftp.gnu.org/gnu/make/make-3.82.tar.gz
Note: If following guide step by step then "cd .." with no quotes from Python-2.7.6 folder

Extract & Change Directory
Code:
tar -xvf make-3.82.tar.gz
cd make-3.82

Install
Code:
./configure
make
sudo make install

You most likely can use apt-get install for the Python and GNU Make but I just prefer this way...

Oracle JDK 6

Code:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
sudo update-java-alternatives -s java-6-oracle
sudo apt-get install oracle-java6-set-default
Note: Use arrow keys on keyboard to navigate confirmation dialogues. You can use OpenJDK with some tweaks but I prefer to use Oracle JDK 6

Git

Code:
sudo apt-get install git

Installing required packages

Code:
sudo apt-get install git gnupg flex bison gperf build-essential
sudo apt-get install zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386
sudo apt-get install libgl1-mesa-dev g++-multilib mingw32 tofrodos
sudo apt-get install python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Bring up AOSP Guide HERE

Continue from Configuring USB Access
To create /etc/udev/rules.d/51-android.rules file type in terminal

Code:
sudo gedit /etc/udev/rules.d/51-android.rules

Make sure to follow AOSP instructions on changing "username" to your login name.

Keep following the guide till the end

Make sure to setup .ccache once repo sync (downloading of source) is complete.

When you are done, reboot system. Once booted click on Dash Home (First icon on side bar), if you notice there is nothing in Dash Home then do the following:

Code:
mv ~/.local/share/zeitgeist ~/.local/share/zeitgeist.bak
 kill -s TERM `pidof /usr/lib/unity-lens-applications/unity-applications-daemon`

Your system is now ready to build AOSP.

Good luck and enjoy!

My new system specs are:
Asus Z87-A Motherboard
i7 4770K
Crucial Ballistix Sport VLP 16GB DDR3-1600
WD Black 1TB
Samsung 840EVO RAID0 - Ubuntu use only
Corsair Hydro Series H80i
Corsair 300R Case
Corsair CX Series CX750M 750 Watt

Build Time ~38 minutes from fresh source download. Have not tried with ccache functioning yet.
 
Last edited:

AndroidUser00110001

Senior Member
Aug 16, 2011
3,432
5,739
NYC
Thanks, followed your directions and I am ready to move on to the next step, but I am unsure. I want to build KitKat for hltetmo, any pointers, maybe another guide on how to continue?

Did the install guide work for you?

You might want to search the net for how to build device tree for CM. There are some good guides out there.

Sent from my LG-D800 using XDA Premium 4 mobile app
 
  • Like
Reactions: ReelFiles

ReelFiles

Senior Member
Jan 29, 2012
1,005
466
Wrong Island
Google Pixel 7 Pro
Go to their github and follow the instructions.

Sent from my LG-D800 using XDA Premium 4 mobile app

I tried and I kept getting repo init errors. The best I could figure out was that it was reading it as an html link rather than a python script. I tried reinstalling python, but to no avail. I am going to try again today.

Now I am getting syntax error near unexpected token 'newline' when trying to setup their gerrit.. this is very offputting. I just wish they would make it more user friendly. I might try a prebuit vm build environment.
 
Last edited:

huggy_72

Senior Member
Aug 29, 2008
358
21
Bologna
To OP

Actualy this

Installing required packages

Code:
[SIZE=5][B][SIZE=2]sudo apt-get install git gnupg flex bison gperf build-essential [COLOR=Red]sudo apt-get install zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev[/COLOR]  sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 sudo apt-get  install libgl1-mesa-dev g++-multilib mingw32 tofrodos sudo apt-get  install python-markdown libxml2-utils xsltproc zlib1g-dev:i386 sudo ln  -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1  /usr/lib/i386-linux-gnu/libGL.so[SIZE=5][B][SIZE=2]
[/SIZE][/B][/SIZE][/SIZE][/B][/SIZE]


Disinstall to much vital component on my system like nvidia drivers....

Code:
[SIZE=5][SIZE=2][SIZE=3][SIZE=5][SIZE=2][SIZE=3][huggy@3xtr3m3:~$ sudo apt-get install zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev
Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze       
Lettura informazioni sullo stato... Fatto
zip è già alla versione più recente.
È stato impostato zip per l'installazione manuale.
libc6-dev è già alla versione più recente.
È stato impostato libc6-dev per l'installazione manuale.
I seguenti pacchetti sono stati installati automaticamente e non sono più richiesti:
  gir1.2-ubuntuoneui-3.0 libubuntuoneui-3.0-1 thunderbird-globalmenu
Usare "apt-get autoremove" per rimuoverli.
I seguenti pacchetti saranno inoltre installati:
  gcc-4.6-base:i386 libc6:i386 libc6-dev:i386 libgcc1:i386 libgpm2:i386
  libncurses5:i386 libtinfo-dev:i386 libtinfo5:i386 linux-libc-dev:i386
  xorg-sgml-doctools
Pacchetti suggeriti:
  glibc-doc:i386 locales:i386 manpages-dev:i386 gpm:i386 ncurses-doc:i386
Pacchetti raccomandati:
  gcc:i386 c-compiler:i386
[COLOR=Red]I seguenti pacchetti saranno RIMOSSI:
  build-essential dkms g++ gcc nvidia-304[/COLOR]
I seguenti pacchetti NUOVI saranno installati:
  curl gcc-4.6-base:i386 libc6:i386 libc6-dev:i386 libgcc1:i386 libgpm2:i386
  libncurses5:i386 libncurses5-dev:i386 libtinfo-dev:i386 libtinfo5:i386
  linux-libc-dev:i386 x11proto-core-dev xorg-sgml-doctools
0 aggiornati, 13 installati, 5 da rimuovere e 2 non aggiornati.
È necessario scaricare 11,0 MB di archivi.
Dopo quest'operazione, verranno liberati 169 MB di spazio su disco.
Continuare [S/n]? s
Scaricamento di:1 http://it.archive.ubuntu.com/ubuntu/ precise/main gcc-4.6-base i386 4.6.3-1ubuntu5 [15,3 kB]
Scaricamento di:2 http://it.archive.ubuntu.com/ubuntu/ precise-updates/main libc6 i386 2.15-0ubuntu10.5 [3949 kB]
Scaricamento di:3 http://it.archive.ubuntu.com/ubuntu/ precise/main libgcc1 i386 1:4.6.3-1ubuntu5 [54,3 kB]
Scaricamento di:4 http://it.archive.ubuntu.com/ubuntu/ precise/main libtinfo5 i386 5.9-4 [90,0 kB]
Scaricamento di:5 http://it.archive.ubuntu.com/ubuntu/ precise/main libncurses5 i386 5.9-4 [116 kB]
Scaricamento di:6 http://it.archive.ubuntu.com/ubuntu/ precise/main libgpm2 i386 1.20.4-4 [16,9 kB]
Scaricamento di:7 http://it.archive.ubuntu.com/ubuntu/ precise-updates/main curl amd64 7.22.0-3ubuntu4.7 [138 kB]
Scaricamento di:8 http://it.archive.ubuntu.com/ubuntu/ precise-updates/main linux-libc-dev i386 3.2.0-59.90 [862 kB]
Scaricamento di:9 http://it.archive.ubuntu.com/ubuntu/ precise-updates/main libc6-dev i386 2.15-0ubuntu10.5 [5107 kB]
Scaricamento di:10 http://it.archive.ubuntu.com/ubuntu/ precise/main libtinfo-dev i386 5.9-4 [93,5 kB]
Scaricamento di:11 http://it.archive.ubuntu.com/ubuntu/ precise/main libncurses5-dev i386 5.9-4 [218 kB]
Scaricamento di:12 http://it.archive.ubuntu.com/ubuntu/ precise/main xorg-sgml-doctools all 1:1.10-1 [12,0 kB]
Scaricamento di:13 http://it.archive.ubuntu.com/ubuntu/ precise-updates/main x11proto-core-dev all 7.0.22-1ubuntu0.1 [300 kB]
Recuperati 11,0 MB in 13s (835 kB/s)                                           
Preconfigurazione dei pacchetti in corso
(Lettura del database... 148290 file e directory attualmente installati.)
[COLOR=Red]Rimozione di nvidia-304...
Removing all DKMS Modules[/COLOR]
Done.
update-alternatives: rimozione delle alternative selezionate manualmente  - viene attivata la modalità automatica per x86_64-linux-gnu_gl_conf
update-alternatives: viene usato  /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf per fornire  /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in  modalità automatica.
update-alternatives: rimozione delle alternative selezionate manualmente  - viene attivata la modalità automatica per i386-linux-gnu_gl_conf
INFO:Disable nvidia-304
DEBUG:Parsing /usr/share/nvidia-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/nvidia-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/nvidia-common/quirks/lenovo_thinkpad
update-initramfs: deferring update (trigger activated)
[COLOR=Red]Rimozione di dkms...
Rimozione di build-essential...
Rimozione di g++...
Rimozione di gcc...[/COLOR]
Elaborazione dei trigger per libc-bin...
ldconfig deferred processing now taking place
Elaborazione dei trigger per man-db...
Elaborazione dei trigger per initramfs-tools...
update-initramfs: Generating /boot/initrd.img-3.8.0-29-generic
Selezionato il pacchetto gcc-4.6-base:i386 non precedentemente selezionato.
(Lettura del database... 148032 file e directory attualmente installati.)
Estrazione di gcc-4.6-base:i386 (da .../gcc-4.6-base_4.6.3-1ubuntu5_i386.deb)...
Selezionato il pacchetto libc6:i386 non precedentemente selezionato.
Estrazione di libc6:i386 (da .../libc6_2.15-0ubuntu10.5_i386.deb)...
Sostituzione dei file nella versione precedente del pacchetto libc6-i386...
Selezionato il pacchetto libgcc1:i386 non precedentemente selezionato.
Estrazione di libgcc1:i386 (da .../libgcc1_1%3a4.6.3-1ubuntu5_i386.deb)...
Selezionato il pacchetto libtinfo5:i386 non precedentemente selezionato.
Estrazione di libtinfo5:i386 (da .../libtinfo5_5.9-4_i386.deb)...
Configurazione di gcc-4.6-base:i386 (4.6.3-1ubuntu5)...
Configurazione di libgcc1:i386 (1:4.6.3-1ubuntu5)...
Configurazione di libc6:i386 (2.15-0ubuntu10.5)...
Configurazione di libtinfo5:i386 (5.9-4)...
Elaborazione dei trigger per libc-bin...
ldconfig deferred processing now taking place
Selezionato il pacchetto libncurses5:i386 non precedentemente selezionato.
(Lettura del database... 148343 file e directory attualmente installati.)
Estrazione di libncurses5:i386 (da .../libncurses5_5.9-4_i386.deb)...
Selezionato il pacchetto libgpm2:i386 non precedentemente selezionato.
Estrazione di libgpm2:i386 (da .../libgpm2_1.20.4-4_i386.deb)...
Selezionato il pacchetto curl non precedentemente selezionato.
Estrazione di curl (da .../curl_7.22.0-3ubuntu4.7_amd64.deb)...
Selezionato il pacchetto linux-libc-dev:i386 non precedentemente selezionato.
Estrazione di linux-libc-dev:i386 (da .../linux-libc-dev_3.2.0-59.90_i386.deb)...
Selezionato il pacchetto libc6-dev:i386 non precedentemente selezionato.
Estrazione di libc6-dev:i386 (da .../libc6-dev_2.15-0ubuntu10.5_i386.deb)...
Selezionato il pacchetto libtinfo-dev:i386 non precedentemente selezionato.
Estrazione di libtinfo-dev:i386 (da .../libtinfo-dev_5.9-4_i386.deb)...
Selezionato il pacchetto libncurses5-dev:i386 non precedentemente selezionato.
Estrazione di libncurses5-dev:i386 (da .../libncurses5-dev_5.9-4_i386.deb)...
Selezionato il pacchetto xorg-sgml-doctools non precedentemente selezionato.
Estrazione di xorg-sgml-doctools (da .../xorg-sgml-doctools_1%3a1.10-1_all.deb)...
Selezionato il pacchetto x11proto-core-dev non precedentemente selezionato.
Estrazione di x11proto-core-dev (da .../x11proto-core-dev_7.0.22-1ubuntu0.1_all.deb)...
Elaborazione dei trigger per man-db...
Configurazione di libncurses5:i386 (5.9-4)...
Configurazione di libgpm2:i386 (1.20.4-4)...
Configurazione di curl (7.22.0-3ubuntu4.7)...
Configurazione di linux-libc-dev:i386 (3.2.0-59.90)...
Configurazione di libc6-dev:i386 (2.15-0ubuntu10.5)...
Configurazione di libtinfo-dev:i386 (5.9-4)...
Configurazione di libncurses5-dev:i386 (5.9-4)...
Configurazione di xorg-sgml-doctools (1:1.10-1)...
Configurazione di x11proto-core-dev (7.0.22-1ubuntu0.1)...
Elaborazione dei trigger per libc-bin...
ldconfig deferred processing now taking place
huggy@3xtr3m3:~$ [/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE]



the other "essential" is not yet tryed no i will repare my system first

 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    So my desktop system died after many years and I just finished building my new system. I stopped cooking ROMs some time ago and it was time to setup my Android build environment again. Last time I did that Google's directions were pretty much straight forward and did not run into any issues. Can't say that for this time, AOSP site needs to update their instructions a bit. I made notes during the process and thought to share them in case anyone finds themselves in a spot like me.

    Use this guide as you follow the instructions at the AOSP website and you should be fine. You can copy and paste all the terminal commands.

    Initializing a Build Environment - Google's Instructions HERE

    Python

    Python 2.6 -- 2.7 - Install dependencies before installing Python
    Code:
    sudo apt-get install build-essential
    sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

    Download Python
    Code:
    cd ~/Downloads/
    wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz

    Extract & Change Directory
    Code:
    tar -xvf Python-2.7.6.tgz
    cd Python-2.7.6

    Install
    Code:
    ./configure
    make
    sudo make install

    GNU Make 3.81 -- 3.82

    Download GNU Make
    Code:
    cd ~/Downloads/
    wget http://ftp.gnu.org/gnu/make/make-3.82.tar.gz
    Note: If following guide step by step then "cd .." with no quotes from Python-2.7.6 folder

    Extract & Change Directory
    Code:
    tar -xvf make-3.82.tar.gz
    cd make-3.82

    Install
    Code:
    ./configure
    make
    sudo make install

    You most likely can use apt-get install for the Python and GNU Make but I just prefer this way...

    Oracle JDK 6

    Code:
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java6-installer
    sudo update-java-alternatives -s java-6-oracle
    sudo apt-get install oracle-java6-set-default
    Note: Use arrow keys on keyboard to navigate confirmation dialogues. You can use OpenJDK with some tweaks but I prefer to use Oracle JDK 6

    Git

    Code:
    sudo apt-get install git

    Installing required packages

    Code:
    sudo apt-get install git gnupg flex bison gperf build-essential
    sudo apt-get install zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev
    sudo apt-get install libx11-dev:i386 libreadline6-dev:i386
    sudo apt-get install libgl1-mesa-dev g++-multilib mingw32 tofrodos
    sudo apt-get install python-markdown libxml2-utils xsltproc zlib1g-dev:i386
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

    Bring up AOSP Guide HERE

    Continue from Configuring USB Access
    To create /etc/udev/rules.d/51-android.rules file type in terminal

    Code:
    sudo gedit /etc/udev/rules.d/51-android.rules

    Make sure to follow AOSP instructions on changing "username" to your login name.

    Keep following the guide till the end

    Make sure to setup .ccache once repo sync (downloading of source) is complete.

    When you are done, reboot system. Once booted click on Dash Home (First icon on side bar), if you notice there is nothing in Dash Home then do the following:

    Code:
    mv ~/.local/share/zeitgeist ~/.local/share/zeitgeist.bak
     kill -s TERM `pidof /usr/lib/unity-lens-applications/unity-applications-daemon`

    Your system is now ready to build AOSP.

    Good luck and enjoy!

    My new system specs are:
    Asus Z87-A Motherboard
    i7 4770K
    Crucial Ballistix Sport VLP 16GB DDR3-1600
    WD Black 1TB
    Samsung 840EVO RAID0 - Ubuntu use only
    Corsair Hydro Series H80i
    Corsair 300R Case
    Corsair CX Series CX750M 750 Watt

    Build Time ~38 minutes from fresh source download. Have not tried with ccache functioning yet.
    1
    Thanks, followed your directions and I am ready to move on to the next step, but I am unsure. I want to build KitKat for hltetmo, any pointers, maybe another guide on how to continue?

    Did the install guide work for you?

    You might want to search the net for how to build device tree for CM. There are some good guides out there.

    Sent from my LG-D800 using XDA Premium 4 mobile app
    1
    Yes it did, thanks. I should have been more specific, I meant to say SlimKat, but that'll have to wait 'til the weekend now.

    Go to their github and follow the instructions.

    Sent from my LG-D800 using XDA Premium 4 mobile app