Execution failed for ':app:ndkBuild'. Process 'command ndk-build.cmd' finished with non-zero exit value 2

那年仲夏 提交于 2019-12-01 06:14:27

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')
}
Ujjwal sinha mahapatra

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 for me
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!