Skip to content Skip to sidebar Skip to footer

Execution Failed For ':app:ndkbuild'. Process 'command Ndk-build.cmd' Finished With Non-zero Exit Value 2

I have been stuck on this problem for 2 days and have tried out all possible solutions given on stackoverflow. Below is my build.gradle file: apply plugin: 'com.android.application

Solution 1:

You should use the latest Android Studio, 2.3.2 is OK. It has integrated externalNativeBuild in android gradle plugin, so you don't need the tricks with custom gradle task.

I could not actually test the build.gradle script below, so please forgive me any typos:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

defaultConfig {
    applicationId "com.example.anannyauberoi.testingcam"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    externalNativeBuild {
        ndkBuild {
            targets "app"
            cppFlags "-std=c++11 -fexceptions"
            arguments "APP_STL=gnustl_shared"
            abiFilters "armeabi-v7a"
        }
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { 
  res.srcDirs = ['src/main/res']
} }

externalNativeBuild {
    ndkBuild {
        path "src/main/jni/Android.mk"
    }
}

    //Modify the below set of code to the ndk-build.cmd location in your computer.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile project(':openCVLibrary249')
}

Solution 2:

I went to:

C:\Users\Dev\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd

directory and for the ndk-build.cmd i press

Right-Click> Edit and change the cmd file from:

@echo off
%~dp0\build\ndk-build.cmd %*

to

@echo off
THAT works forme

Post a Comment for "Execution Failed For ':app:ndkbuild'. Process 'command Ndk-build.cmd' Finished With Non-zero Exit Value 2"