Your APP_BUILD_SCRIPT points to an unknown file using Android ndk-build

Viewed 45300

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.

17 Answers

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'
    }
}

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.

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.

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

Related