I've set up the AOSP master branch on my machine and have tried to build using the following steps:
source build/envsetup.sh
lunch aosp_bullhead-userdebug
make -j4
Here is the output of make:
============================================
PLATFORM_VERSION_CODENAME=P
PLATFORM_VERSION=P
TARGET_PRODUCT=aosp_bullhead
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=cortex-a53
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=cortex-a53.a57
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.13.0-37-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
============================================`
ninja: no work to do.
[1/1] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l
out/.module_paths/Android.bp.list -b out/soong -n out -d
out/soong/build.ninja.d -o out/soong/build.ninja Android.bp
error: development/build/Android.bp:30:1: "android_stubs_current" depends on undefined module "api-stubs-docs"
error: development/build/Android.bp:38:1: "android_system_stubs_current" depends on undefined module "system-api-stubs-docs"
error: development/build/Android.bp:46:1: "android_test_stubs_current" depends on undefined module "test-api-stubs-docs"
ninja: build stopped: subcommand failed.
10:39:54 soong bootstrap failed with: exit status 1
#### failed to build some targets (4 seconds) ####
The version of Java that is being used is the bundled openjdk 9 (The same error occurs with openjdk 8)
java -version
openjdk version "9"
OpenJDK Runtime Environment (build 9+181-android4627429)
OpenJDK 64-Bit Server VM (build 9+181-android4627429, mixed mode)