Giter VIP home page Giter VIP logo

v8forandroid's Introduction

V8ForAndroid

V8 build setting for android (arm, arm64, x86) on Linux (Ubuntu).

Complie V8 for Android

V8

Create android NDK project

It is assumed that you have compiled armeabi-v7a, arm64-v8a, x86.

  1. import include, armeabi-v7a, arm64-v8a, x86, include folder
app
-- libs
   -- arm64-v8a
   -- armeabi-v7a
   -- x86
   -- include
  1. edit CMakeLists.txt file
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

# import libv8_base.a called v8_base
add_library( v8_base STATIC IMPORTED )
set_target_properties( v8_base PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libv8_base.a )

# import libv8_nosnapshot.a called v8_nosnapshot
add_library( v8_nosnapshot STATIC IMPORTED )
set_target_properties( v8_nosnapshot PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libv8_nosnapshot.a )

add_library( native-lib SHARED src/main/cpp/native-lib.cpp )
target_include_directories( native-lib PRIVATE ${CMAKE_SOURCE_DIR}/libs/include )

target_link_libraries( native-lib v8_base v8_nosnapshot log )

  1. add cmake option in build.gragle
cmake {
    cppFlags "-std=c++11 -frtti -fexceptions"
    abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
    arguments "-DANDROID_UNIFIED_HEADERS=ON"
}
  1. add function in native-lib.cpp
// return value is version of v8
Java_com_leibniz55_v8test_MainActivity_getVersion(
        JNIEnv *env,
        jobject /* this */) {
    const char* utfString = v8::V8::GetVersion();
    return env->NewStringUTF(utfString);
}
  1. add native java function in MainActivity
public native String getVersion();

  1. call getVersion()
TextView tv = (TextView) findViewById(R.id.sample_text);
tv.setText(getVersion());
  1. run application
version of v8 will appear on the screen.

Author

devikkim, [email protected]

v8forandroid's People

Contributors

devikkim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.