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.
Related
I'm trying to build ' linphone-android ' .
link to git repo
Somehow i manged to resolv all the bugs but now i'm stuck at when i try to run ' ./prepare.py **' commanad in terminal it giving me NDK ERROR i.e **ERROR: The following binaries are missing: ndk-build. Please install them.
I have ndk path in .bash file also but unable to resolve this error.
Please share some solution
Thanks :)
I am assuming that you have added android-sdk and android-ndk path in your environment. If not then you can add sdk and ndk path using below command.
export PATH=/Users/kaushik512/Library/Android/sdk/platform-tools/:/Users/kaushik512/Library/Android/sdk/tools/:/Users/kaushik512/Downloads/android-ndk-r12b/:/nobackup/local/prog/nasm/bin:$PATH
export PATH=/opt/local/bin/:$PATH
after adding path check using echo $PATH.
Add above in PATH and see if issue resolved.
Do check the version of ndk in your android studio. I was facing the same problem and my ndk version was 16 so I changed it to 15 it worked but also I made the project again and followed the steps one by one as given in the repository, the same link that you have provided.
Hope that helps.
I am building an Android project using Eclipse and native code. 95% of the time this works fine, but every now and then it decides to give me the following error:
make: [libs/armeabi/libnative.so] Error 1
make: Deleting file `libs/armeabi/libnative.so'
Libnative being the native library I am creating. Sometimes running the build again works fine, other times it just fails again and again. OTHER times it works for days.
What is this and how do I stop it from happening?
If anyone has the same problem try deleting the .so file from your repository and commit that change. I do not know why, but it worked for me.
This issue can be fixed by these steps:
clean project in eclipse
run ndk-build clean
run ndk-build
If it can't work, try delete *.so in libs folder and delete obj folder, then run above steps.
Hope this can help for others.
If this is only happening when generating your APK, try disabling 'Build Automatically' when exporting. See my question here.
A computer restart fixed this for me
To fix the issue just change the cdt.managedbuild.tool.gnu.assembler.base tool id within the .cproject file of your eclipse Android project. This ID seems to be identical with that of the other project you have just built. You may have copied the project to upgrade and the same id appeared. I changed 1798454924 to 1798454925 and the error was gone.
tool id="cdt.managedbuild.tool.gnu.assembler.base.1798454924" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"
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?
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.
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.
I had the same problem and although the description at http://developer.android.com/tools/sdk/ndk/index.html#Installing for installing the NDK is good, it does not cover the solution to this frequent problem.
Eclipse seems to allow you to configure stuff in multiple places, you can do global modifications via Window menu or project specific configurations via the Properties option. Simplest is to add full path for ndk-build (ndk-build.cmd for windows) in the {Properties; C/C++ Build} Build command box.
The easier solution, build with the command ndk-build from eclipse project path:
$PROJECT>ndk-build
Everytime you change your native code.
To compile on eclipse, i followed the next steps:
Create the eclipse project.
Add the native code (.cpp) at jni folder
Create Android.mk and Application.mk following the typically 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 eclipse throw warnings, put your mouse on jni code part, and check the option: "convert project to native code", and will convert the project automatically.
Next time you compile, ndk-build V=1 will be called, compiling native code, and then, compile Android part.
NOTE:
You must be able to use ndk-build in all folder on your system. The command detect where has been called, and look for the jni folder, to use the Android.mk to compile all native code.
The basic structure that look for is:
$PROJECT>jni/
/Android.mk
/Application.mk
/code.cpp
But you can modify Android.mk to look for code in other paths.
I hope it help you!
Sequoya is your friend. It is a part of Eclipse since Indigo release.
http://www.eclipse.org/sequoyah/
In my case, I had to give complete path to my ndk-build.cmd command in eclipse in order for it to build:
Eclipse -> Your Prj -> Right Click -> C/C++ Build
C:\Prateek\android-ndk-r9\ndk-build.cmd
Just in case you are somehow only seeing your stdout and not stderr, try redirecting your stderr to stdout.
ndk-build 2>&1
make sure to use "absolutepath\ndk-build.cmd" instead "absolutepath\ndk-build" in windows.
It compiles without error with .cmd added
In addition to system environment.
In Eclipse, You also need to go to preferences->c/c++ Build -> environment. Add a new variable with the name "NDKROOT" and value set to the NDK installation path.
This works for me.
Newly, I want to work with FBReader. I took it's codes from github and download Android NDK and cygwin. But I have several problems.
I need your help for config and use these codes. I install Cygwin and try to config it but I get the following error in codes:
1. I get error in main.xml : "error: No resource identifier found for attribute 'fadeScrollbars' in package 'android' "
2. I get errors in src/... : " The import org.geometerplus.zlibrary.ui.android.R cannot be resolved " (for line: import org.geometerplus.zlibrary.ui.android.R; )
3. In HowToBuild file I don't understand which create 'local.properties' file and how to set address for sdk.dir && ndk.dir
4. In .bashrc file where should I insert parameters? (which line)
5. Does Android NDK should config? How?
I search and study a lot of, But I can't use FBReader. Could you help me, please?
By the way, I used Eclipse.
Thanks and Regards, Omid
you may build NDK using cmd.
ndk-build -C your_project_location
this link will help you.
This is what I did: I downloaded and extracted the NDK. Then I ran the NDK-build command on the project directory in CMD:
cd: <PROJECT SOURCE DIRECTORY>
<PATH-TO-NDK FOLDER>\ndk-build
After its built, follow steps inside of the FBBuilder readme. Setting the path are super easy. Create file local.properties in the root of FBReader project, and inside it enter the SDK and NDK paths just as shown in the readme. If you have winodws, your path would be something like this C:\android\android_ndk, etc.
Once you do that, you should come across the following error: org.geometerplus.zlibrary.ui.android.R is unresolved. This even I don't know how to fix. I'm currently researching this.
I was also getting the same problem. First try to resolve other issues in your project. This file is generated automatically by your sdk, so don't bother about that. Also the package name in your manifest file must be same as below:-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.geometerplus.zlibrary.ui.android"
android:installLocation="auto"
android:versionCode="108021"
android:versionName="1.8.2" >
As soon as other errors will be resolved,sdk will create this file when you refresh project or clean the project.
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.