Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK in Eclipse :: (Cannot run program "ndk-build": Unknown reason)

I am loosing my mind trying to build my NDK project from eclipse using the CDT plugin and i get the error:-

NDK (Cannot run program "ndk-build": Unknown reason)

The application runs but i loose all of the console output for the build process, this is a nightmare when trying to compile and i have to do it on the command line.

This is how i got there:-

I Downloaded and installed the CDT plugin for Eclipse.

Then:

Added my JNI folder and also your Android.mk in the JNI directory.

Then:

Go FILE / NEW / OTHER /C/C++ / ( Convert to a C/C++ Project )

On setting up my build target:

Check the project, choose MakeFile Project and Other Toolchain click NEXT

Then finally in project properties:

PROJECT / PROPERTIES / C/C++ uncheck " use default build command" replace "make" with "ndk-build" 

Then when it builds it spits the error to the console. Though it compiles and makes the build which runs on the device i cant see any of the build output.

I have "ndk-build' in my .bash_profile with the following variables:

:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK

I can compile using ndk-build from command line fine. It seems that Eclipse cant see my PATH:

This is on Mac OSX, in Helios version 2.

EDIT: Ok so this compiles fine, and the output from the build is infact hidden underneath this message, this is far from ideal, as when i need to review what items have been built i cant as its covered up. How do i get rid of it?

like image 696
Dev2rights Avatar asked Mar 08 '12 15:03

Dev2rights


2 Answers

In my case, I had to give complete path to my ndk-build command in eclipse in order for it to build:

Eclipse -> Your Prj -> Right Click -> C/C++ Build -> "Builder" group: the value for "Build command" should be complete path something like below (instead of just "ndk-build")

/Users/vshakya/MySoftware/android-ndk-r8/ndk-build

I hope this will help others in future for I just wasted like 30 minutes to figure this out.

like image 72
Viren Avatar answered Oct 22 '22 20:10

Viren


It might seem stupid but have you check if there are several consoles ? I can imagine there is one for the message you quoted, and another for build output.

See also this : the answer has an interesting link, dealing with setup but also related to eclipse integration.

like image 41
rockeye Avatar answered Oct 22 '22 20:10

rockeye