Close

Building Android, by the book: Build it.

A project log for Breaking Android™

Building and breaking the Android AOSP on the BBB. Android is a trademark of Google Inc.

jlbrian7jlbrian7 03/11/2017 at 16:410 Comments

References:

https://source.android.com/source/building.html

'Embedded Android' by Karim Yaghmour

. build/envsetup.sh

Output:

including device/asus/deb/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/asus/fugu/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/htc/flounder/vendorsetup.sh
including device/huawei/angler/vendorsetup.sh
including device/lge/bullhead/vendorsetup.sh
including device/lge/hammerhead/vendorsetup.sh
including device/moto/shamu/vendorsetup.sh
including sdk/bash_completion/adb.bash

lunch 

Output:

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. aosp_deb-userdebug
8. aosp_flo-userdebug
9. full_fugu-userdebug
10. aosp_fugu-userdebug
11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_mips-userdebug
14. mini_emulator_x86_64-userdebug
15. mini_emulator_x86-userdebug
16. aosp_flounder-userdebug
17. aosp_angler-userdebug
18. aosp_bullhead-userdebug
19. aosp_hammerhead-userdebug
20. aosp_hammerhead_fp-userdebug
21. aosp_shamu-userdebug



Which would you like? [aosp_arm-eng]

>press [Enter] to build for the emulator.

Output:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-64-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_BUILD_TYPE=release
BUILD_ID=MOB31S
OUT_DIR=out
============================================

make -j4

Output:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-64-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_BUILD_TYPE=release
BUILD_ID=MOB31S
OUT_DIR=out
============================================
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.

Your version is: openjdk version "1.8.0_121" OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13) OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode).
The required version is: "1.7.x"

Please follow the machine setup instructions at
https://source.android.com/source/initializing.html
************************************************************
build/core/main.mk:171: *** stop. Stop.



#### make failed to build some targets (14 seconds) ####

I did follow those instructions, but there has been an update to the OpenJDK., and I am building one version of the AOSP behind the current. So roll the JDK back.

sudo apt-get purge openjdk-8-jdk
sudo apt-get autoremove

#http://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher
sudo add-apt-repository ppa:openjdk-r/ppa  
sudo apt-get update
sudo apt-get install openjdk-7-jdk 
make -j4

Output:

...

target SharedLib: libc (out/target/product/generic/obj/SHARED_LIBRARIES/libc_intermediates/LINKED/libc.so)
Install: out/target/product/generic/system/lib/libdl.so
out/host/linux-x86/bin/checkseapp -p out/target/product/generic/obj/ETC/sepolicy_intermediates/sepolicy -o out/target/product/generic/obj/ETC/seapp_contexts_intermediates/seapp_contexts out/target/product/generic/obj/ETC/seapp_contexts_intermediates/seapp_contexts.tmp
Install: out/target/product/generic/root/sepolicy
Install: out/target/product/generic/root/service_contexts
Writing local settings in /home/jeramy/.jack
Stopping background server
ERROR: No Jack server running
Killing background server
ERROR: No Jack server to kill
touch out/host/common/obj/JAVA_LIBRARIES/jack_intermediates/kill_server.stamp
Install: out/host/linux-x86/framework/signapk.jar
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_shared_library_internal.mk:51: recipe for target 'out/host/linux-x86/obj/lib/libart.so' failed
make: *** [out/host/linux-x86/obj/lib/libart.so] Error 1
make: *** Waiting for unfinished jobs....
warning: string 'gsm_alphabet_default_charset' has no default translation.



#### make failed to build some targets (04:44:50 (hh:mm:ss)) ####

http://oopsmonk.github.io/blog/2016/06/07/android-build-error-on-ubuntu-16-04-lts

I applied the above fix, and got this error:

host C++: libart <= art/runtime/mirror/method.cc
host C++: libart <= art/runtime/mirror/object.cc
host C++: libart <= art/runtime/mirror/reference.cc
/tmp/array-25da80.s: Assembler messages:
/tmp/array-25da80.s:1973: Internal error!
Assertion failure in get_line_subseg at /usr/local/google/home/chh/workdir/precise7/toolchain-src/binutils/binutils-2.23/gas/dwarf2dbg.c line 272.
Please report this bug.
clang++: error: assembler command failed with exit code 1 (use -v to see invocation)
build/core/binary.mk:706: recipe for target 'out/host/linux-x86/obj/SHARED_LIBRARIES/libart_intermediates/mirror/array.o' failed
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libart_intermediates/mirror/array.o] Error 1
make: *** Waiting for unfinished jobs....



#### make failed to build some targets (02:33:01 (hh:mm:ss)) ####

upon receiving that error I removed the last line in the flags and made my HOST_x86_common.mk file look the same as it does here:

https://android-review.googlesource.com/#/c/223100/

Creating filesystem with parameters:
Size: 1610612736
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 6144
Label: system
Blocks: 393216
Block groups: 12
Reserved block group size: 95
Created filesystem with 1675/98304 inodes and 139519/393216 blocks
Install system fs image: out/target/product/generic/system.img
out/target/product/generic/system.img+ maxsize=1644333504 blocksize=2112 total=1610612736 reserve=16610880



#### make completed successfully (03:30:45 (hh:mm:ss)) ####

Total build time was ~6hrs. on an AMD Athlon(tm) 5350 APU with Radeon(tm) R3 with 4 cores using `make -j8`

Test the build:

emulator &

wait for a long long time, and:

Discussions