Android NDK in Eclipse :: (Cannot start "ndk-build" program: unknown reason)

I lose consciousness while trying to build my NDK project from eclipse using the CDT plugin and I get an error: -

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

The application starts, but I lose all the console output for the build process, this is a nightmare when I try to compile, and I have to do it on the command line.

Here's 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 ) 

When setting up my build target:

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

Then, finally, in the project properties:

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

Then, when he builds, he lays an error on the console. Although it compiles and makes an assembly that works on the device, I cannot see any output from the assembly.

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 the command line. It seems that Eclipse can not see my PATH:

This is on Mac OSX, in Helios 2 version.

EDIT: Okay, so this compiles fine, and the output from the compilation is hidden under this message, this is far from ideal, because when I need to see what elements were built, I cannot close them. How can I get rid of it?

+7
source share
10 answers

This may sound silly, but are you checking to see if there are multiple consoles? I can imagine that for the message you specify one and the other to output the assembly.

See also this : the answer contains an interesting link related to customization, but also related to eclipse integration.

+4
source

In my case, I needed to give the full path to my ndk-build command in eclipse so that it was created:

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

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

I hope this helps others in the future, as I just wasted like 30 minutes to figure it out.

+13
source

Please refer to this link to configure NDK in android

http://odroid.foros-phpbb.com/t181-how-to-install-android-ndk

+5
source

I had the same problem, and although the description of http://developer.android.com/tools/sdk/ndk/index.html#Installing for installing NDK is good, it does not cover the solution to this problem, a common problem.

Eclipse seems to allow you to configure files in several places, you can make global changes through the Window menu or specific project configurations through the Properties option. The easiest way is to add the full path for ndk-build (ndk-build.cmd for windows) in {Properties; C / C ++ Build} Create a command line.

+4
source

A simpler solution, create using the ndk-build command from the eclipse project path:

 $PROJECT>ndk-build 

Every time you change your own code.

To compile eclipse, I followed these steps:

  • Create an eclipse project.
  • Add custom code (.cpp) to jni folder
  • Create Android.mk and Application.mk following a typical structure
  LOCAL_PATH: = $ (call my-dir)
 include $ (CLEAR_VARS)

 LOCAL_SRC_FILES: = $$ Add source files $$

 LOCAL_LDLIBS: = -lpcap

 LOCAL_MODULE: = libtest

 LOCAL_C_INCLUDES: = $$ Path of the header files used $$

 include $ (BUILD_SHARED_LIBRARY)

 ----------------

 Aplication.mk depends that the type of options you want
  • When you run the eclipse warnings, hover over a part of the jni code and check the option: "convert the project to native code" and automatically convert the project.

The next time you compile, ndk-build V = 1 is called, compiles its own code, and then compiles the Android part.

Note:

You should be able to use ndk-build in all folders of your system. The team discovers where it was called, and looks for the jni folder to use Android.mk to compile all native code.

The main structure that is looking for:

  • $ PROJECT> JNI /
    • /Android.mk
    • /Application.mk
    • /code.cpp

But you can change Android.mk to look for code in other ways.

Hope this helps you!

+3
source

Sequoia is your friend. This is part of Eclipse since the release of Indigo.

http://www.eclipse.org/sequoyah/

+3
source

In my case, I had to give the full path to my ndk-build.cmd command in eclipse so that it could build:

Eclipse -> Your Prj -> Right Click -> C / C ++ Build

C: \ Prateek \ android-ndk-r9 \ ndk-build.cmd

+3
source

Just in case, you somehow see only your stdout and not stderr, try redirecting stderr to stdout.

ndk-build 2> & 1

+2
source

be sure to use "absolutepath \ ndk-build.cmd" instead of "absolutepath \ ndk-build" in windows. It compiles without errors with the addition of .cmd.

+1
source

In addition to the system environment.

In Eclipse, you also need to go to settings -> c / C ++ Build -> environment. Add a new variable named "NDKROOT" and the value set for the NDK installation path.

This works for me.

0
source

All Articles