NDK build error - android

Hi I am new to Android NDK Development.
MacBook-Pro:JNIexample sk$ ndk-build
usage: dirname path
gmake: /Users/sk/build/core/build-local.mk: No such file or directory
gmake: *** No rule to make target `/Users/sk/build/core/build-local.mk'. Stop.
Why do I get his error?

So I was having the same trouble, and it looks like if I have any directory which is a part of full dir-path which has dir-name with space (' ') in between then 'ndk-build' wont be able to resolve paths. So my directory name "development tools" wasnt good enough so I changed it to "developmenttools" and it worked. If I hard-code the path in 'ndk-build' then it was working so found out the reason.

You need to specify the project you want to build. Like this: ndk-build -C location_of_project.
For example, to build the hello-neon sample that comes with the NDK you would go to your ndk install root and do ndk-build -C samples/hello-neon

The ndk-build tool is actually just a wrapper that calls gmake with the build-local.mk file. It finds the build-local.mk file by creating a relative path rooted at the location of the ndk-built tool. Sounds like you don't have the full NDK installed, or maybe moved the ndk-build tool without moving the rest of the NDK contents?

I also faced this problem. And i solved it and post entire answer here. I hope it helps you.

Please notice that from the error message:
gmake: /Users/sk/build/core/build-local.mk: No such file or directory.
The build/core/builid-local.mk is actually in the ndk's root directory, why is it listed as the /Users/username/build…?
I've encountered the same error on my Macbook. I've put the ndk inside /Applications/Android Studio.app directory, since there is a space between the name, somehow the tool in ndk can't resolve the implied path. That's why the error message is printed.
Later I renamed Android Studio.app to Android-Studio.app and thus resolved the issue.

The solution for me was different. If you look in the ndk-build script, you see it immediately runs `dirname $0` to get the directory to work in.
I was calling "ndk-build" from my command line, which was using a copy of the ndk-build script that I had put in /usr/local/bin/ and so my error was '/usr/local/bin/build/core/build-local.mk: No such file or directory'.
The solution is to be in the ndk folder where the real ndk-build script lives, and use the -C /path/to/project option to tell it where to start. So, 'cd /path/to/ndk' and then run './ndk-build -C /path/to/project'

I was having same problem. I created new workspace and import existing project to it. But forgot to add ndk location in windows->preferences->Android->NDK.

Related

APP_BUILD_SCRIPT points to an unknown file [duplicate]

I get the following error while trying to compile an Android NDK project:
ndk-build
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: /home/lambergar/work/APIExample/jni/Android.mk
/home/lambergar/android/ndk/android-ndk-r5c/build/core/add-application.mk:116: *** Android NDK: Aborting... . Stop.
The weird thing is, that the 'unknown file' (Android.mk) exists under the path reported as invalid.
Same problem (in Windows 7) but the cause is different.
After searching in the Environment parameters, I've found the evil thing named "NDK_PROJECT_PATH" which has value is an invalid path.
Deleted it and things are working again ;)
In my case the problem was with white spaces in the project path. In such case, change the project path folders and import the project again.
Just saw this problem today.
In my case actual problem was spaces inside path to project.
(yes, ndk-build will not compile your project if you have spaces inside folder name)
I just had the same problem. I fixed it by creating a Application.mk in $NDK/apps/ndktestapp with following content:
APP_PROJECT_PATH := /cygdrive/c/workspace/MyApp
and then calling
make APP=ndktestapp
from the NDK-Root. Hope that helps.
I solved the problem by adding a new build to the project and voila, it works... Don't know what was the problem with the CLI build though.
You need to set the env variable NDK_PROJECT_PATH to the root of the project you are building. The root of your NDK project will typically contain the ./jni directory.
export NDK_PROJECT_PATH={root_of_project}
If your JNI code is in a library, then set NDK_PROJECT_PATH to the library project.
Do not make any white space in the Project Directory. If errors come again
then edit the build.gradle(Module:app) below buildTypes block and add those line like below:
buildTypes {
release {
......................
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni/','src/main/jniLibs/'] } }
externalNativeBuild {
ndkBuild {
path 'build/intermediates/ndk/debug/Android.mk'
}
}
Just spent an hour or two trying to figure this one out. Many, many people have had this problem. But as I found out I actually did not have a file name Android.mk it was named Andriod.mk and that was enough to cause me a lot of trouble. Sorry about my original rant but that was the whole problem in the end. I suggest if you have this problem you should check everything until you find something wrong.
This fixed me right up. Thanks guys you put me on the right track anyway.
Please remove these directories
rm -rf .externalNativeBuild //if exits
rm -rf app/.externalNativeBuild
rm -rf app/.cxx/ //if exits
rm -rf app/build/
then rebuild the project.
as the same as #phavens, i think that only wrong with the word Android.mk and android.mk file, just spent for 5 minutes .. hehe
in my case the project folder name had a space in it removed the space re imported it to Android Studio and that solved the problem
Details of the problem:
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: /jni/Android.mk
...: *** Android NDK: Aborting... . Stop.
Usually this is not the path of your project, so the reason for this error is that ndk could not find the correct Android.mk file path.
solution:
Add NDK_PROJECT_PATH to "./" in the environment variable, the purpose is to tell the NDK that the jni currently to be compiled is located in the directory where the project is located.
I encountered similiar probblems as in this topic. My solution is: firstly check the file exist in the correct path. Secondly, if your path have any whitespace, remove it or relocate your project to a simple path. Then rebuild it.
I just installed Android-NDK and tried "ndk-build".
I had exactly the same error. Here is how I beat it.
bash
export NDK_PROJECT_PATH={root_of_android_ndk}/samples/hello-jni
./ndk-build
This worked.
Inside Android.mk file, you give the path where the jni folder loacted...
in your case
ARTOOLKIT_DIR :=/home/lambergar/work/APIExample/
For me, deleted the .gradle and app/.externalNativeBuild directories and it worked.
I also had space in the path for one of the folders. I struggled for 2-3 hrs understanding the problem and wondering why it said it is not able to find a file in a path which I was able to see. On seeing answers here, I removed space in one of the foldername in the path and voila, it started working.
Gradle Experimental plugein in Android Studio add support for Native project build.

Ant Build Android Project With Dependencies

I'm trying to build an app (let's call it android-app) with a dependency on an SDK (let's call it sdk) via Ant. Eclipse is not installed on this computer (for reasoning, it's a CI box with Jenkins).
Both projects are in two completely separate directories side by side. android-app is in the directory ~/.jenkins/jobs/android-app/workspace and sdk is in the directory ~/.jenkins/jobs/sdk/workspace.
Let's assume both projects are "vanilla" and have not been built with Ant before. I cd to the ../android-app/workspace directory and run android update project -p . --library ~/.jenkins/jobs/sdk/workspace which passes. I then cd to the ../sdk/workspace directory and run android update project -p . which also passes.
At this point I cd back to the ../android-app/workspace directory and run ant clean build. It fails with the error:
BUILD FAILED
/path/to/ant/build.xml:440:
/path/to/sdk/workspace resolve to a path with no project.properties file for
project /path/to/android-app/workspace
... where /path/to is the full path to the directories. I simplified it here.
If I cd to the sdk workspace and open project.properties, I receive the following:
# ProGuard
proguard.config=proguard.cfg
# Project target.
target=android-10
android.library=true
It does exist. So do all of these files:
So, why is this failing? What am I doing wrong? I tried to provide as many details as possible. Please let me know if I can provide anything additional.
Well, I encounter this problem too.
I use strace to find out what the hell is going on and found that the path you specified in project.properties will be appended with your current folder path as its prefix.
For example,
/home/myfolder/project > ant debug
And the library you specified in project.properties is /path/to/library
Then, the path will become
/home/myfolder/project/path/to/library
Just to fill in the answer gap here, my Java version was completely off. I'm super embarrassed.

project_create.sh: line 4: android: command not found (cygwin&android&jni)

http://www.stanford.edu/class/ee368/Android/Tutorial-2-OpenCV-for-Android-Setup-Windows.pdf
This is the tutorial I am following and I stucked in the JNI to opencv library
according to the steps I had run project_create.sh in cugwin and come up with the result project_create.sh: line 4: android: command not found
Then I created a project_create.bat file with line android update project --name android-opencv --path .\ copy project.properties default.properties
BUT it also come up with android is not recognized as an internal or external command/ operable program or batch file.
Both .sh and .bat didn't work and I couldn't move on. Because ant step depend on it
Could someone give me any idea how to fix it??
Thank you!
Android is an executable located in <path-to-your-SDK>/tools/. Unless your working directory is tools, or you have added it to your PATH, you will get this error.
To fix it, either edit the script to use the full path, or copy paste the files into the tools directory and run them.
Okay finally I made it!
First of all, modified project_create.sh put the path to android like C:/cygwin/home/Joyce/SDK/tools/android update project --name android-opencv --target 2 \ --path
And better add up the target too because you don't have to deal with the "target not found" problem.
Second of all, don't run it in cygwin terminal, run "sh ./project_create.sh" in windows terminal.
Thirdly, make sure ant\bin had been added up to PATH, then can run "ant debug" in windows terminal.
Finally, got "BUILD SUCCESSFUL"! JNI to opencv library done!

Android NDK: ndk-build script fails - script "check-cygwin-make.mk" not found

I'm new to development with the NDK of Android.
As I'm developing on Win7 I installed Cygwin in order to build the native binaries.
When running ndk-build from the project folder /home/simon/ndk/hello-neon I get the error
ERROR: You are using a non-Cygwin compatible Make program.
Currently using: C:/Programs/cygwin/bin/make
To solve the issue, follow these steps:
1. Ensure that the Cygwin 'make' package is installed.
NOTE: You will need GNU Make 3.81 or later!
2. Define the GNUMAKE environment variable to point to it, as in:
export GNUMAKE=/usr/bin/make
3. Call 'ndk-build' again.
The problem that stops me now is that the ndk-build script seems not to be able to call the check-cygwin-make.mk script in the following lines:
GNUMAKE=`cygpath -u $GNUMAKE`
PROGDIR_MIXED=`cygpath -m $PROGDIR`
CYGWIN_GNUMAKE=`$GNUMAKE -f "$PROGDIR_MIXED/build/core/check-cygwin-make.mk" 2>&1`
When calling
echo $CYGWIN_GNUMAKE
I get the reply:
make: C:/Programs/cygwin/home/simon/build/core/check-cygwin-make.mk: No such fil
e or directory make: AndroidManifest.xml build.properties default.properties jni
res src No rule to make target `C:/Programs/cygwin/home/simon/build/core/check-
cygwin-make.mk'. Stop.
Now I'm lost because I don't understand the role of the check-cygwin-make.mk script and I could not find it anywhere on my drive.
I'm aware of the problem with spaces in the C:/Program Files/ folder name, and I think this is not problem now.
I hope someone can help my to solve this issue,
Regards,
Simon
Install android-ndk and cygwin(with "make" support command) then set the varaibles like this
Right-click My Computer, and then click Properties.
Click the Advanced tab.
Click Environment variables.
then edit"PATH" add this line
C:\cygwin\bin like this
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files......;C:\cygwin\bin
then try with your built steps
'check-cygwin-make.mk' is in '\android-ndk-r6b\build\core', and you should have installed Android NDK to a directory without spaces in the path.
Next you should be running ndk-build either from Cygwin-shell, or with the command 'bash -c ndk-build'.
And of course the necessary paths both to Cygwin binaries (as in the previous answer), and to ndk-build should be specified in PATH.

How to set GNUMAKE variable for ndk-build to work

I am trying to make ndk-build to work within Cygwin on windows. As per the NDK documentation (specifically INSTALL.htm), "The NDK requires GNU Make 3.81 or later being available on your development."
I have Gnu Make installed on my computer.
So far, so good.
Within Cygwin bash, I cd over to the android NDK root directory. Now when I type in the following command (without parameters right now, just to see if the command works):
$./ndk-build
ERROR: Cannot find 'make' program. Please install Cygwin make package or define the GNUMAKE variable to point to it.
So I try to set the GNUMAKE variable, but no luck:
$export GNUMAKE='/cygdrive/c\Program Files\GnuWin32\bin'
ERROR: Your GNUMAKE variable is defined to an invalid name: /cygdrive/c\Program Files\GnuWin32\bin
Please fix it to point to a valid make executable (e.g. usr/bin/make)
I even tried setting it to usr/bin/make as it suggests, but same invalid name error.
Anyone, knows how to resolve this?
I'm using Windows 7, NDK r5, Cygwin 1.7.1
I had an issue with GNUMake when putting the ndk in a folder with a space in it (I originally put it in the program files directory). I moved everything to C:/android/android-ndk and C:/android/android-sdk and updated my path settings to include these directories.
Its not problem with the make but installing cygwin
in ndk-demo script the make path is found using which command mostly which command
installation is missing in cygwin.
Solution:
Relaunch your cygwin installation select utils (install )
Checking:
$ which make
should give you the make command path on cygwin prompt.
Regards,
Vasu
This is a generic error. It means there was a problem somehow with the make command, but the error message itself is hidden. To help diagnose the problem, open your ndk_build script in the ndk directory, and change these lines:
ABS_GNUMAKE=`which $GNUMAKE 2> /dev/null`
...
GNUMAKE=`which make 2> /dev/null`
to these:
ABS_GNUMAKE=`which $GNUMAKE`
...
GNUMAKE=`which make`
And then you will get a more detailed error message. Note that it might not even be a problem with the 'make' command, it might be a problem with the 'which' command. Make sure you have cygwin installed.
delete Environmental variable GNUMAKE
close the cygwin terminal
open again cygwin terminal... go the path where u want to build.. and now build it...
I am sure hopefully you will build successfully..as i do..
The answer with moving NDK to a directory without spaces is definitely right. After that you will probably able to run ndk-build from the Cygwin shell.
However running ndk-build from Windows commmand line (like "bash ndk-build") will probably cause the same queer error with "incorrect GNU make".
It is reproducible with NDK 6b as well.
And I hope it is fixed in the newest version of NDK...
ERROR: Cannot find 'make' program. Please install Cygwin make package
or define the GNUMAKE variable to point to it.
While trying to install Cygwin i missed out to install MAKE PACKAGE
Just need to search make in the Search box and it will shows the Branches that includes devel branch and from devel branch i selected make package.
That's all issue fixed.
i worked hard on error in gygwin terminal "gnumake variable is define to invalid name" and after that i get to the point that we simply remove this error by deleting the GNUMAKE path in environment variable both in system and user variable if u created it hope its helps....
mycomputer > system properties > advanced system setting > environment variable
The problem here is the name of the GNUMAKE variable.The name given was
/cygdrive/c\Program Files\GnuWin32\bin change it into /cygdrive/c/Program Files/GnuWin32/bin/make
only use forword Slash .Sometime the space in the folder structure does not taken
Happy coding.

Categories

Resources