Android问题集锦之四十: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

参考:

http://stackoverflow.com/questions/14156596/ndk-cant-find-the-application-directory

时间: 2024-11-04 06:05:11

Android问题集锦之四十:Android NDK: Could not find application project directory的相关文章

Android问题集锦之四十九:Can&#39;t add XStream file dependency to Android Studio project

将xstream1.4.8 引入Android Strudio项目中,编译报错如下: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) at

Android问题集锦之四十八:Error:duplicate files during packaging of APK

端午小长假最后一天,大雨.只好在家里鼓捣自己喜欢的代码了. 在将dom4j.jar也加入fastjson测试程序中,编译出错,如下: Error:duplicate files during packaging of APK /home/linc/workspace/lab/FastjsonTestor/app/build/outputs/apk/app-debug-unaligned.apk Path in archive: META-INF/LICENSE.txt Origin 1: /ho

Android问题集锦之四十二:INSTALL_FAILED_OLDER_SDK

错误描述如下: $ adb install ./app/build/outputs/apk/app-debug.apk 2999 KB/s (8256380 bytes in 2.688s) pkg: /data/local/tmp/app-debug.apk Failure [INSTALL_FAILED_OLDER_SDK] 原因就是您设备的Android版本过低,app不支持. 改正的办法就是在程序的Manifest文件(或build.gradle)中将最低版本号调高. Manifest中

Android实战技巧之四十四:Hello,Native!

在Android上运行C程序对于做上层App的童鞋来说有些陌生,因为目前的Android应用开发怎么还是绕不过Java. 但对于底层驱动开发者,这就是家常便饭一样,因为Android是Linux分支,底层是C/C++的世界. 有时为了测试一些功能,我们也会编写直接运行在Android终端下的C程序.前提是有Android交叉编译器以及Android系统的root权限. 交叉编译工具 ndk为我们开发native程序做了很多工作,下面我们将Android交叉编译工具从ndk中分离出来. 我的系统是

Android实战技巧之四十九:Usb通信之USB Host

零 USB背景知识 USB是一种数据通信方式,也是一种数据总线,而且是最复杂的总线之一. 硬件上,它是用插头连接.一边是公头(plug),一边是母头(receptacle).例如,PC上的插座就是母头,USB设备使用公头与PC连接. 目前USB硬件接口分三种,普通PC上使用的叫Type:原来诺基亚功能机时代的接口为Mini USB:目前Android手机使用的Micro USB. Host USB是由Host端控制整个总线的数据传输的.单个USB总线上,只能有一个Host. OTG On The

【转】Android实战技巧之四十九:Usb通信之USB Host

零 USB背景知识 USB是一种数据通信方式,也是一种数据总线,而且是最复杂的总线之一. 硬件上,它是用插头连接.一边是公头(plug),一边是母头(receptacle).例如,PC上的插座就是母头,USB设备使用公头与PC连接. 目前USB硬件接口分三种,普通PC上使用的叫Type:原来诺基亚功能机时代的接口为Mini USB:目前Android手机使用的Micro USB. Host USB是由Host端控制整个总线的数据传输的.单个USB总线上,只能有一个Host. OTG On The

Android studio 使用心得(十)---android studio 多渠道打包(三)

关于使用android studio 如何打包  大家可以看这两篇文章 Android studio 使用心得(四)---android studio 多渠道打包 Android studio 使用心得(四)---android studio 多渠道打包(二) 真正的项目开发,当然是建议 Android studio 使用心得(四)---android studio 多渠道打包(二) 其实,android studio 对上面这种打包方式还有更简单的方法,就是使用as 里面自带的Terminal

Android实战技巧之四十:Android5.1.1源代码编译与烧写

购买Nexus手机的朋友大多是为了自己修改系统玩,再加上其较高的性价比,在开发者中还是广受欢迎的.我的5太子被我升级到了6.0预览版,玩的正嗨,舍不得换回到5.1时代了.不过鉴于距6.0源码发布还有段日子,5.1的源码编译与烧写仍是主流,下面就记录了整个过程(持续了很长时间,我们要有耐心). 搭建开发环境 系统推荐Ubuntu 14.04 1.openjdk is needed $ sudo apt-get update $ sudo apt-get install openjdk-7-jdk

Android问题集锦之三十八:not allowed to send broadcast android.intent.action.MEDIA_MOUNTED

当我们保存图片后就会发个通知告诉系统让sdcard重新挂载,这样其他程序就会立即找到这张图片. Intent intent = new Intent(); intent.setAction(Intent.ACTION_MEDIA_MOUNTED); intent.setData(Uri.fromFile(Environment .getExternalStorageDirectory())); sendBroadcast(intent); 但是到了Android4.4就不灵了,Google将ME