How to fix NDK build error for HelloCardboard sample


I am trying to compile Google Cardboard Sdk sample.

I am following instructions given by google’s official docs

I am stuck at step 3, where I am supposed to assemble the project:

enter image description here

This is the error I am getting when I start to assemble:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':hellocardboard-android:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process C:\Users\Shanu\AppData\Local\Android\Sdk\cmake\\bin\ninja.exe with arguments {-C C:\Projects\cardboard\hellocardboard-android\.cxx\cmake\debug\x86 cardboard_jni}
  ninja: Entering directory `C:\Projects\cardboard\hellocardboard-android\.cxx\cmake\debug\x86'

  ninja: error: '../../../../libraries/jni/x86/', needed by '../../../../build/intermediates/cmake/debug/obj/x86/', missing and no known rule to make it

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

29 actionable tasks: 2 executed, 27 up-to-date
1:55:12 PM: Task execution finished 'assemble'.

Then I tried to run with --stacktrace

Caused by: org.gradle.internal.UncheckedException: Build command failed.

But there is an additional warning:

WARNING: This app only has 32-bit [armeabi-v7a,x86] native libraries. Beginning August 1, 2019 Google Play store requires that all apps that include native libraries must provide 64-bit versions. For more information, visit

Well, that doesn’t give me an idea, as to have never used NDK/Cardboard SDK ever before.

Here is how the build.gradle(hellocardboard) looks like:

apply plugin: ''

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId ""
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        externalNativeBuild {
            cmake {
                cppFlags "-stdgnu++11"
                arguments "-DANDROID_STLc++_shared"
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), ''
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
    compileOptions {
        sourceCompatibility  '1.8'
        targetCompatibility  '1.8'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation ''
    implementation ''
    // Android Mobile Vision
    implementation ''
    //noinspection GradleCompatible
    implementation ''
    implementation project(":sdk")

// The dependencies for NDK builds live inside the .aar files so they need to
// be extracted before NDK targets can link against.
task extractNdk(type: Copy)  {
    if (file("${project.rootDir}/sdk/build/outputs/aar/sdk-release.aar").exists()) {
        copy {
            from zipTree("${project.rootDir}/sdk/build/outputs/aar/sdk-release.aar")
            into "libraries/"
            include "jni/**/"
        copy {
            from "${project.rootDir}/sdk/include/cardboard.h"
            into "libraries/"

task deleteNdk(type: Delete) {
    delete "libraries/jni"
    delete "libraries/cardboard.h"


Here is the whole project hosted on my GitHub

Everything is at google’s default settings, and I haven’t configured anything, except Install these components from the SDK manager:

  • CMake
  • LLDB
  • NDK (Side by Side)

What is the issue here and how can I fix it?


This usually happens when you haven’t built the SDK.

The sample app tells you to click the “assemble” option in the Gradle tab. You should click the “assemble” option under “:sdk”, not the one under “:hellocardboard-android”.

The official instructions are unclear about this; it is only visible if you look closely at the screenshots there.

Answered By – S.L. Barth

Leave a Comment