Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NDKBuild Failure

I'm having trouble getting my NDK to compile properly in Android Studio. Whenever I try running to compile I am getting the following error.

Error:Execution failed for task ':app:ndkBuild'. A problem occurred starting process 'command 'ndk-build.cmd''

I have the following setup

enter image description here

And my build.gradle file is the following.

import org.apache.tools.ant.taskdefs.condition.Os  apply plugin: 'com.android.application'  android {     compileSdkVersion 21     buildToolsVersion "21.1.2"      defaultConfig {         applicationId "edu.uky.cs.www.diagramaphone"         minSdkVersion 14         targetSdkVersion 21         versionCode 1         versionName "1.0"          sourceSets.main{             jniLibs.srcDir 'src/main/libs'             jni.srcDirs = [] //disable automatic ndk-build call         }         project.ext.versionCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9] //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*         android.applicationVariants.all { variant ->             // assign different version code for each output             variant.outputs.each { output ->                 output.versionCodeOverride =                         project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + defaultConfig.versionCode             }         }         // call regular ndk-build(.cmd) script from app directory         task ndkBuild(type: Exec) {             if (Os.isFamily(Os.FAMILY_WINDOWS)) {                 commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath             } else {                 commandLine 'ndk-build', '-C', file('src/main').absolutePath             }         }         tasks.withType(JavaCompile) {             compileTask -> compileTask.dependsOn ndkBuild         }         //ndk {           //  moduleName "shape-detect"             //cFlags "-DANDROID_NDK -D_DEBUG DNULL=0" // Define some macros             //ldLibs "EGL", "GLESv3", "dl", "log"         // Link with these libraries!             //stl "stlport_shared"                        // Use shared stlport library         //}      }     buildTypes {         release {             minifyEnabled false             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  dependencies {     compile fileTree(include: ['*.jar'], dir: 'libs')     compile 'com.android.support:appcompat-v7:21.0.3'     compile project(':libraries:tess-two')     compile project(':libraries:opencv') } 

At this point I'm lost as to what can be wrong. I've followed several tutorials to try setting up the NDK to work properly, but I keep getting the error I showed above. Can anyone here provide some feedback on what I need to do in order to get the NDK to compile?

EDIT: Here's the entire message that occurs.

Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :libraries:opencv:compileLint :libraries:opencv:copyReleaseLint UP-TO-DATE :libraries:opencv:mergeReleaseProguardFiles UP-TO-DATE :libraries:opencv:preBuild UP-TO-DATE :libraries:opencv:preReleaseBuild UP-TO-DATE :libraries:opencv:checkReleaseManifest :libraries:opencv:prepareReleaseDependencies :libraries:opencv:compileReleaseAidl UP-TO-DATE :libraries:opencv:compileReleaseRenderscript UP-TO-DATE :libraries:opencv:generateReleaseBuildConfig UP-TO-DATE :libraries:opencv:generateReleaseAssets UP-TO-DATE :libraries:opencv:mergeReleaseAssets UP-TO-DATE :libraries:opencv:generateReleaseResValues UP-TO-DATE :libraries:opencv:generateReleaseResources UP-TO-DATE :libraries:opencv:packageReleaseResources UP-TO-DATE :libraries:opencv:processReleaseManifest UP-TO-DATE :libraries:opencv:processReleaseResources UP-TO-DATE :libraries:opencv:generateReleaseSources UP-TO-DATE :libraries:opencv:compileReleaseJava UP-TO-DATE :libraries:opencv:processReleaseJavaRes UP-TO-DATE :libraries:opencv:packageReleaseJar UP-TO-DATE :libraries:opencv:compileReleaseNdk UP-TO-DATE :libraries:opencv:packageReleaseJniLibs UP-TO-DATE :libraries:opencv:packageReleaseLocalJar UP-TO-DATE :libraries:opencv:packageReleaseRenderscript UP-TO-DATE :libraries:opencv:bundleRelease UP-TO-DATE :libraries:tess-two:compileLint :libraries:tess-two:copyReleaseLint UP-TO-DATE :libraries:tess-two:mergeReleaseProguardFiles UP-TO-DATE :libraries:tess-two:preBuild UP-TO-DATE :libraries:tess-two:preReleaseBuild UP-TO-DATE :libraries:tess-two:checkReleaseManifest :libraries:tess-two:prepareReleaseDependencies :libraries:tess-two:compileReleaseAidl UP-TO-DATE :libraries:tess-two:compileReleaseRenderscript UP-TO-DATE :libraries:tess-two:generateReleaseBuildConfig UP-TO-DATE :libraries:tess-two:generateReleaseAssets UP-TO-DATE :libraries:tess-two:mergeReleaseAssets UP-TO-DATE :libraries:tess-two:generateReleaseResValues UP-TO-DATE :libraries:tess-two:generateReleaseResources UP-TO-DATE :libraries:tess-two:packageReleaseResources UP-TO-DATE :libraries:tess-two:processReleaseManifest UP-TO-DATE :libraries:tess-two:processReleaseResources UP-TO-DATE :libraries:tess-two:generateReleaseSources UP-TO-DATE :libraries:tess-two:compileReleaseJava UP-TO-DATE :libraries:tess-two:processReleaseJavaRes UP-TO-DATE :libraries:tess-two:packageReleaseJar UP-TO-DATE :libraries:tess-two:compileReleaseNdk UP-TO-DATE :libraries:tess-two:packageReleaseJniLibs UP-TO-DATE :libraries:tess-two:packageReleaseLocalJar UP-TO-DATE :libraries:tess-two:packageReleaseRenderscript UP-TO-DATE :libraries:tess-two:bundleRelease UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE :app:prepareDiagramaphoneLibrariesOpencvUnspecifiedLibrary UP-TO-DATE :app:prepareDiagramaphoneLibrariesTessTwoUnspecifiedLibrary UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:ndkBuild FAILED Error:Execution failed for task ':app:ndkBuild'. > A problem occurred starting process 'command 'ndk-build.cmd'' Information:BUILD FAILED Information:Total time: 2.226 secs Information:1 error Information:0 warnings Information:See complete output in console 
like image 350
Valrok Avatar asked Apr 20 '15 03:04

Valrok


People also ask

What is Ndk_project_path?

NDK_PROJECT_PATH - the location of your project NDK_APPLICATION_MK - the path of the Application.mk file APP_BUILD_SCRIPT - the path to the Android.mk file. These are needed to override the default values of the build script, which expects things to be in the jni folder.

What is NDK build Android?

The NDK allows Android application developers to include native code in their Android application packages, compiled as JNI shared libraries. See the Getting Started Guide for an introduction. See the changelist for a list of changes since the previous release.


2 Answers

I met this kind of problem. First of all You have to give your NDK path in local.properties of your app.

e.g. ndk.dir=/home/user/bin/android_ndk/android-ndk-r10e

Then in my build.gradle file I had something like this for calling ndk build command.

commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath 

I'v change it to

commandLine '/home/user/bin/android_ndk/android-ndk-r10e/ndk-build', '-C', file('src/main/jni').absolutePath 

I gave full path of NDK build. Hope it'll help you.

like image 116
Hayk Nahapetyan Avatar answered Sep 30 '22 01:09

Hayk Nahapetyan


In android studio, File->Project Structure -> SDK Location, Set the Android NDK location for your computer.

Thanks!

like image 23
jungwook Avatar answered Sep 30 '22 00:09

jungwook