31

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.

jww
  • 97,681
  • 90
  • 411
  • 885
LambergaR
  • 2,433
  • 4
  • 24
  • 34
  • 3
    try to build your project with the flag NDK_LOG set to 1: that is $NDK/ndk-build NDK_LOG=1 to see more information about this error... maybe [this](http://groups.google.com/group/android-ndk/browse_thread/thread/1c8511da02fa5e3d) helps you.. – Thanasis Petsas Jun 27 '11 at 16:02

18 Answers18

25

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 ;)

Obelisk Sparrow
  • 251
  • 3
  • 2
  • This is important! Other suggestions may lead people to add the NDK_PROJECT_PATH environment variable and point it to the NDK directory or something. If this exists, and you try to compile a new project, it will complain because it's looking for files in the NDK_PROJECT_PATH. I just ran into the same stupid issue. This solved it. – James Stone Aug 14 '15 at 10:06
19

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.

Shayan Amani
  • 5,787
  • 1
  • 39
  • 40
8

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)

Anton Malmygin
  • 3,406
  • 2
  • 25
  • 31
5

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.

sege
  • 81
  • 1
  • 7
3

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.

Peter Gluck
  • 8,168
  • 1
  • 38
  • 37
Wakahiu Njenga
  • 113
  • 1
  • 7
3

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'
    }
}
Istiyak
  • 693
  • 6
  • 15
  • Although this is not an accepted answer (because there is no white space in project path), it help me find the problem in my project. – amrezzd Jul 16 '19 at 08:23
3

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.

LambergaR
  • 2,433
  • 4
  • 24
  • 34
3

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.

jww
  • 97,681
  • 90
  • 411
  • 885
phavens
  • 94
  • 4
2

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.

Mushahid Gillani
  • 723
  • 7
  • 19
  • This fixed the issue for me. I had recently refactored my module name in Android Studio. The old project folder name had been cached in the `.externalNativeBuild` configuration files (which store the args passed into ndk-build) – Hamy Apr 03 '20 at 16:34
  • No help for me, building without android studio (just ndk-build), although weirdly in my case, I have the exact same .mk files for another project that does work. – Soylent Graham Aug 09 '20 at 13:29
1

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

puputCantik
  • 119
  • 5
  • Gradle paths seem to be case sensitive, even on Windows! `android.mk != Android.mk`. – l33t Dec 29 '18 at 22:15
1

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

rn0rdin
  • 26
  • 5
1

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.

冯剑龙
  • 569
  • 8
  • 22
  • This was my fix! My `ndk-build NDK_PROJECT_PATH=/xxx/` command line was incorrect [path] where `/xxx/` matches `/xxx/jni/android.mk` – Soylent Graham Aug 09 '20 at 13:35
1

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.

Mingze Li
  • 360
  • 1
  • 10
0

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.

Lenvanthis
  • 71
  • 1
  • 6
0

Inside Android.mk file, you give the path where the jni folder loacted... in your case ARTOOLKIT_DIR :=/home/lambergar/work/APIExample/

0

For me, deleted the .gradle and app/.externalNativeBuild directories and it worked.

A.A
  • 2,603
  • 1
  • 18
  • 22
0

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.

Lokesh
  • 23
  • 4
-1

Gradle Experimental plugein in Android Studio add support for Native project build.

Sadegh Ghanbari
  • 1,271
  • 15
  • 29