## Android NDK: Could not find application project directory
记得前阵子编译so库直接使用ndk-build搞定,今天使用却报错如下:
~~~
$ ndk-build
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/opt/android-ndk-r10b/build/core/build-local.mk:148: *** Android NDK: Aborting . Stop.
~~~
高人支招如下:
~~~
You need to specify 3 things.
NDK_PROJECT_PATH - the location of your project
NDK_APPLICATION_MK - the path of the Application.mk file
APP_BUILD_SCRIPT - the path to the Android.mk file
These are needed to override the default values of the build script, which expects things to be in the jni folder.
When calling ndk-build use
ndk-build NDK_PROJECT_PATH=/path/to/proj NDK_APPLICATION_MK=/path/to/Application.mk
In Application.mk add
APP_BUILD_SCRIPT := /path/to/Android.mk
~~~
首先第一步,在Application中加入Android.mk路径
比如这两个文件是同级的:
~~~
APP_BUILD_SCRIPT := Android.mk
~~~
第二步,直接编译:
~~~
$ ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk
[armeabi-v7a] Compile++ thumb: detection_and_recognition_lib <= DetectionAndRecognition.cpp
[armeabi-v7a] Prebuilt : libopencv_java.so <= /home/linc/workspace/lab/OpenCV-android-sdk-2.4.11/sdk/native/jni/../libs/armeabi-v7a/
[armeabi-v7a] SharedLibrary : libdetection_and_recognition_lib.so
/opt/android-ndk-r10b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /opt/android-ndk-r10b/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/thumb/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libopencv_java.so
[armeabi-v7a] Install : libdetection_and_recognition_lib.so => libs/armeabi-v7a/libdetection_and_recognition_lib.so
[armeabi-v7a] Prebuilt : libnative_camera_r4.3.0.so <= /home/linc/workspace/lab/OpenCV-android-sdk-2.4.11/sdk/native/jni/../libs/armeabi-v7a/
[armeabi-v7a] Install : libnative_camera_r4.3.0.so => libs/armeabi-v7a/libnative_camera_r4.3.0.so
[armeabi-v7a] Prebuilt : libnative_camera_r4.4.0.so <= /home/linc/workspace/lab/OpenCV-android-sdk-2.4.11/sdk/native/jni/../libs/armeabi-v7a/
[armeabi-v7a] Install : libnative_camera_r4.4.0.so => libs/armeabi-v7a/libnative_camera_r4.4.0.so
[armeabi-v7a] Install : libopencv_java.so => libs/armeabi-v7a/libopencv_java.so
[x86] Compile++ : detection_and_recognition_lib <= DetectionAndRecognition.cpp
[x86] Prebuilt : libopencv_java.so <= /home/linc/workspace/lab/OpenCV-android-sdk-2.4.11/sdk/native/jni/../libs/x86/
[x86] SharedLibrary : libdetection_and_recognition_lib.so
[x86] Install : libdetection_and_recognition_lib.so => libs/x86/libdetection_and_recognition_lib.so
[x86] Prebuilt : libnative_camera_r4.3.0.so <= /home/linc/workspace/lab/OpenCV-android-sdk-2.4.11/sdk/native/jni/../libs/x86/
[x86] Install : libnative_camera_r4.3.0.so => libs/x86/libnative_camera_r4.3.0.so
[x86] Prebuilt : libnative_camera_r4.4.0.so <= /home/linc/workspace/lab/OpenCV-android-sdk-2.4.11/sdk/native/jni/../libs/x86/
[x86] Install : libnative_camera_r4.4.0.so => libs/x86/libnative_camera_r4.4.0.so
[x86] Install : libopencv_java.so => libs/x86/libopencv_java.so
~~~
各位大虾也许看出来了,我在编译OpenCV相关的项目。而现在的设备选型已经涵盖了x86架构,所以编译时要选择x86指令集编译。在Application.mk中注明如下:
~~~
APP_ABI := armeabi-v7a x86
~~~
后记:
放到jni目录下就不用此命令了!
> 参考:
> [http://stackoverflow.com/questions/14156596/ndk-cant-find-the-application-directory](http://stackoverflow.com/questions/14156596/ndk-cant-find-the-application-directory)
- 前言
- Android问题集锦转载之一
- Android问题集锦之一
- Android问题集锦之二
- Android问题集锦之三
- Android问题集锦转载之二
- Android问题集锦转载之三
- Android问题集锦之四
- Android问题集锦转载之四
- Android问题集锦转载之五
- Android问题集锦之六
- Android问题集锦之七
- Android问题集锦之八
- Android问题集锦之九
- Android问题集锦之十
- Android问题集锦之十一
- android问题集锦之十二
- Android问题集锦转载之六
- Android问题集锦之十三
- Android问题集锦之十四
- Android问题集锦转载之七
- Android问题集锦之十五
- Android问题集锦转载之八
- Android问题集锦之十六
- Android问题集锦之十七
- android问题集锦之十八
- Android环境问题集锦之十九
- Android问题集锦之二十
- Android问题集锦之二十一
- Android问题集锦之二十二
- Android问题集锦之二十三
- Android问题集锦之二十四
- Android问题集锦之二十五
- Android问题集锦之二十六
- Android问题集锦之二十七
- Android问题集锦之二十八
- Android问题集锦之二十九
- Android问题集锦之三十
- Android问题集锦之三十一
- Android问题集锦之三十二
- Android问题集锦之三十三
- Android问题集锦之三十四
- Android问题集锦之三十五
- Android问题集锦之三十六
- Android问题集锦之三十七
- Android问题集锦之三十八
- Android问题集锦之三十九
- Android问题集锦之四十
- Android问题集锦之四十一
- Android问题集锦之四十二
- Android问题集锦之四十三
- Android问题集锦之四十四
- Android问题集锦之四十五
- Android问题集锦之四十六