Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is a possible solution using Android.bp (the Soong replacement for the Andoird make based built system). It works for the example found in the Android tree at (android-8.1.0_r52)


Now when typing "mm" i.e.

android-8.1.0_r52/development/ndk/tests/prebuilt-library/jni$ mm

The prebuilt shared libraries are linked and their export includes are found. Here are the steps (I'm in the process of trying this with my opencv project):

  1. android-8.1.0_r52/$ . build/
  2. android-8.1.0_r52/$ lunch -> select #29 bullhead
  3. cd development/ndk/tests/prebuilt-library/jni
  4. Build 32-bit and 64-bit export BUILD_FOO=1 mm
  5. mkdir lib lib64 cp $OUT/system/lib/ lib/ cp $OUT/system/lib64/ lib64/
  6. Rename to ("bu" for backup)
  7. Replace the $(gettop)/Android.bp with the Android.bp-top below (rename to Android.bp)
    • or simply add this line to the existing Android.bp: "development/ndk/tests/prebuilt-library/jni",
  8. Copy attached Android.bp to development/ndk/tests/prebuilt-library/jni
  9. mm

The steps above result in a native executable in a foo-user_exe in bullhead/system/bin/

Although this means I have to rewrite my existing into a Android.bp, there are tools that can do this for you. i.e. "androidmk > Android.bp"


subname = "Android.bp"

build = [

subdirs = [

optional_subdirs = [

And the Android.bp

cc_prebuilt_library_shared {
    name: "libfoo",
    vendor: true,
    compile_multilib: "both",
    export_include_dirs: ["foo"],
    target: {
        android_arm: {
            srcs: ["lib/"],
        android_arm64: {
            srcs: ["lib64/"],
    strip: {

cc_library_shared {
    name: "foo-user",
    srcs: ["foo-user.c"],
    shared_libs: ["libfoo"],

cc_binary {
    name: "foo-user_exe",
    srcs: ["foo-user.c"],
    shared_libs: ["libfoo"],
    stl: "none",