Compile v8 arm, arm64, ia32

Quick guide on how to compile v8 8.4-lkgr for Android on Ubuntu in one copy/paste script. I use this script regularly, so it is well tested.

If you are looking for some already pre-compiled ready-to-use v8 version, you can find them here.

# Install git:
sudo apt install git

# Install depot tools
Follow instructions

# Fetch v8 source code.
# Use the branch of your choice. In will use 8.4-lkgr (last known good release).
# I'd advise always using -lkgr branches
fetch v8
cd v8
git pull
git checkout 8.4-lkgr

# Enter v8 folder.
cd v8

# Install all dependencies, ndk, sdk, etc.
# This may take a while. It downloads android tools: sdk+ndk, etc.

# Set android target. This op will take some time, ndk alone is +1Gb
echo "target_os = ['android']" >> ../.gclient && gclient sync

# Generate compilation target: 
# Change android_arm.release to the folder name of your choice, in this
# case:
# Use this to compile for arm/arm64
tools/dev/ arm.release

# Use this to compile for x86
tools/dev/ ia32.release

# Edit gn configuration file: 
# I’d recommend disabling icu support, and set 
# symbol_level=0 for faster compilation and thinner
# output libs. You can get the whole list of 
# compilation options by executing: 
# `gn args —-list` 
# Optionally set `target_cpu="arm64"` or `target_cpu="x86"` (if ia32 was used)


# This is my file contents:
android_unstripped_runtime_outputs = false
is_component_build = false
is_debug = false
symbol_level = 1
target_cpu = "arm"
target_os = "android"
use_goma = false
use_custom_libcxx = false
use_custom_libcxx_for_host = false
v8_target_cpu = "arm"
v8_use_external_startup_data = false
v8_enable_i18n_support= false
v8_android_log_stdout = true
v8_static_library = true
v8_monolithic = true
v8_enable_pointer_compression = false

# to compile arm64, just change target_cpu and v8_target_cpu to arm64

# Compile target: 
# This may take up to 1 hour depending on your setup.
# Optionally use a -j value suitable for your system.
ninja -C v8_monolithic

# Fat lib file has been generated by v8_monolithic parameter at
#<e.g. android_arm.release>/obj/libv8_monolithic.a 

# source headers, for inspector compilation.
mkdir -p src/base/platform
mkdir -p src/common
mkdir -p src/inspector
mkdir -p src/json
mkdir -p src/utils
mkdir -p src/init

cp -R ../../../../src/common/*.h ./src/common
cp -R ../../../../src/base/*.h ./src/base
cp -R ../../../../src/base/platform/*.h ./src/base/platform
cp -R ../../../../src/inspector/*.h ./src/inspector
cp -R ../../../../src/json/*.h ./src/json
cp -R ../../../../src/utils/*.h ./src/utils
cp -R ../../../../src/init/*.h ./src/init

# copy v8 compilation header files:
cp -R ../../../../include ./

# For compilation on Android, always use the same ndk as 
# `gclient sync` downloaded. 
# Enjoy v8 embedded in an Android app

Compile for Android emulator

tools/dev/ gen ia32.release
# edit, to contain the following:
is_debug = false
target_cpu = "x86"
use_goma = false
target_os = "android"
v8_use_external_startup_data = false
v8_enable_i18n_support = false
v8_monolithic = true

Published by ibon

Chocolate engineer, software eater. Cool stuff at Past: Workday, Platochat, SdkBox, Chukong, Ludei.

4 thoughts on “Compile v8 arm, arm64, ia32

  1. Hi
    I needed to built v8 with NDK version 21 which was different than what gclient sync downloaded. So i changed the ndk paths used by v8 to refer to NDK version 21 paths. After building for arm64 and x86_64 and using libv8_monolith.a files in android studio, the project runs successfully.
    But for 32-bit devices ( i.e. arm and x86), though the build is successful, the android project crashes. I am not able to find any specific argument that might be needed for building v8 for 32-bit devices. Could you please suggest where i might be wrong?
    I have used the following arguments to build v8 for arm:

    target_os = “android”

    is_debug = true

    is_component_build = false

    target_cpu = “arm”

    v8_target_cpu = “arm”

    v8_enable_pointer_compression = false

    clang_use_chrome_plugins = false






    1. That config file looks correct to me.
      Since you have debug+symbol_level, you should be able to get an accurate grasp of when things derail.
      For x86, you need to set `target_cpu = “x86″` (simulator). But the arm should work straight away. Maybe you can share some stack traces.


  2. Hi,
    I am trying to build V8 for the android x86 arch, I have followed the above-shared steps but am getting the following error while integrating with the android sample app.

    [x86] SharedLibrary :
    D:/workspace/v8workspace/SampleV8v8.x/app/src/main/cpp/hello-jni.cpp:42: error: undefined reference to ‘v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, v
    8::platform::InProcessStackDumping, std::__ndk1::unique_ptr<v8::TracingController, std::__ndk1::default_delete >)’
    ../../buildtools/third_party/libc++/trunk/include/vector:1027: error: undefined reference to ‘std::__1::__vector_base_common::__throw_length_error() const’
    ../../src/api/ error: undefined reference to ‘std::__1::__vector_base_common::__throw_length_error() const’
    ../../buildtools/third_party/libc++/trunk/include/memory:3498: error: undefined reference to ‘std::__1::__shared_weak_count::__release_weak()’

    Please help.



    1. Two potential things here:

      have you tried `use_custom_libcxx=false` as config param ?
      Also, NDK has a different sodlib prefix. for android, and more specifically on latest versions, I must have had to make a change in `v8/buildtools/third_party/libc++/trunk/include/__config` file:

      set `_LIBCPP_CONCAT(__ndk,_LIBCPP_ABI_VERSION)`, so that stdlib’s prefix changes from __1 to __ndk1
      Hope that helps.


Leave a Reply to Deeksha Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: