How to build android

2018-06-16  本文已影响0人  lucientlau

Use sudo apt-get purge command to remove the alert when i sudo apt-get install to install any software.

lut@lut-X405UA:/usr$ sudo apt-get purge oracle-java6-installer
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
.
.
.

when you dont see the start menu, using the following command to reinstall the desktop and related software, eg. terminal, firfox, and so on.

  sudo apt-get install --reinstall ubuntu-desktop
  sudo apt-get install unity  

after that use sudo shutdown -r now to restart the system.

set repo

$ mkdir ~/bin
$ PATH=~/bin:$PATH

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

repo command ref

using the follow command to switch python3 to virtual python2 enviroment
about how to construct virtualenv pls see ref

lut@lut-X405UA:~/Downloads$ source ~/anaconda3/bin/pyenv/bin/activate

using this command to downloads android source code

(pyenv) lut@lut-X405UA:~/Downloads/androidsource$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/

the repo config is in~/.reopconfig/

the reason of using --repo-url it that because if you dont add this item will response
mirror of tsinghua

 fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle

then use

repo sync

install jdk8

sudo apt-get update
sudo apt-get install openjdk-8-jdk

install jdk7

sudo add-apt-repository ppa:openjdk-r/ppa 
sudo apt-get update
sudo apt-get install openjdk-7-jdk 

switch of different jdk version

sudo update-alternative --config java
sudo update-alternative --config javac
or
sudo update-alternatives --config java
sudo update-alternatives --config javac

relate lib dependency on ubuntu16.04

sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib 
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386 
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential  
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib 
sudo apt-get install libc6-dev-i386 
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev 
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install lib32z-dev ccache

initial complier environments

source build/envsetup.sh

lunch select complier target

lunch aosp_arm64-eng  # or only use lunch command then select the target

switch to python2 environments

lut@lut-X405UA:~/anaconda3/bin$ virtualenv -p /usr/bin/python2.7 pyenv
source ~/anaconda3/bin/pyenv/bin/activate

start build

sudo make -j8

-j8 means use 8 threads to build the project.

next

sourch build/envsetup.sh

initial build environment
then lunch

 
lut@lut-X405UA:/media/lucient/59A633800E2D6D3D/androidsource$ lunch 

You're building on Linux

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
     7. full_fugu-userdebug
     8. aosp_fugu-userdebug
     9. aosp_car_emu_arm-userdebug
     10. aosp_car_emu_arm64-userdebug
     11. aosp_car_emu_x86-userdebug
     12. aosp_car_emu_x86_64-userdebug
     13. mini_emulator_arm64-userdebug
     14. m_e_arm-userdebug
     15. m_e_mips64-eng
     16. m_e_mips-userdebug
     17. mini_emulator_x86_64-userdebug
     18. mini_emulator_x86-userdebug
     19. uml-userdebug
     20. aosp_cf_x86_auto-userdebug
     21. aosp_cf_x86_phone-userdebug
     22. aosp_cf_x86_tablet-userdebug
     23. aosp_cf_x86_tablet_3g-userdebug
     24. aosp_cf_x86_tv-userdebug
     25. aosp_cf_x86_wear-userdebug
     26. aosp_cf_x86_64_auto-userdebug
     27. aosp_cf_x86_64_phone-userdebug
     28. aosp_cf_x86_64_tablet-userdebug
     29. aosp_cf_x86_64_tablet_3g-userdebug
     30. aosp_cf_x86_64_tv-userdebug
     31. aosp_cf_x86_64_wear-userdebug
     32. cf_x86_auto-userdebug
     33. cf_x86_phone-userdebug
     34. cf_x86_tablet-userdebug
     35. cf_x86_tablet_3g-userdebug
     36. cf_x86_tv-userdebug
     37. cf_x86_wear-userdebug
     38. cf_x86_64_auto-userdebug
     39. cf_x86_64_phone-userdebug
     40. cf_x86_64_tablet-userdebug
     41. cf_x86_64_tablet_3g-userdebug
     42. cf_x86_64_tv-userdebug
     43. cf_x86_64_wear-userdebug
     44. aosp_dragon-userdebug
     45. aosp_dragon-eng
     46. aosp_marlin-userdebug
     47. aosp_marlin_svelte-userdebug
     48. aosp_sailfish-userdebug
     49. aosp_walleye-userdebug
     50. aosp_walleye_test-userdebug
     51. aosp_taimen-userdebug
     52. aosp_angler-userdebug
     53. aosp_bullhead-userdebug
     54. aosp_bullhead_svelte-userdebug
     55. hikey-userdebug
     56. hikey960-userdebug

Which would you like? [aosp_arm-eng] 1 # select the same item with upon

============================================
PLATFORM_VERSION_CODENAME=P
PLATFORM_VERSION=P
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.13.0-26-generic-x86_64-Ubuntu-16.04.3-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=OC-MR1
OUT_DIR=out
============================================
lut@lut-X405UA:/media/lucient/59A633800E2D6D3D/androidsource$ ls

finally
run emulator

lut@lut-X405UA:/media/lucient/59A633800E2D6D3D/androidsource$ emulator
emulator: WARNING: system partition size adjusted to match image file (2050 MB > 200 MB)

emulator: WARNING: encryption is off
emulator: INFO: boot completed

上一篇下一篇

猜你喜欢

热点阅读