67

运行 ndk-build 命令时出现以下错误:

Android NDK: Could not find application project directory !    
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.

我的 Android.mk 文件的内容:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := FRE
LOCAL_SRC_FILES := FlashRuntimeExtensions.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := NativeQCAR
LOCAL_SRC_FILES := main.c
LOCAL_SHARED_LIBRARIES := FRE
include $(BUILD_SHARED_LIBRARY)

添加以下行没有帮助:

NDK_PROJECT_PATH = C:/Users/Wessel/Dropbox/workspace/eclipse/NativeQ
4

11 回答 11

27

您可以使用以下命令

ndk-build -C your_project_path

希望这能回答你的问题。

于 2013-10-07T07:46:02.727 回答
26

NDK_PROJECT_PATH is an environment variable so you don't have to include in the Android.mk file. Is nkd-build launched in the project directory?

For more info read the docs in docs/HOWTO.html in the NDK folder where I read

Starting with NDK r4, you can simply place the file under $PROJECT/jni/ and launch the 'ndk-build' script from your project tree.

If you want to use 'ndk-build' but place the file to a different location, use a GNU Make variable override as:

ndk-build NDK_APPLICATION_MK=/path/to/your/Application.mk
于 2013-01-04T11:55:22.023 回答
19

I haven't found a single answer which is satisfactory for me, perhaps it depends whether you're trying to build an existing application, create a new one, or perhaps you are porting some existing native app. These guidelines work with android-ndk-r9b but should work with the last few releases

The makefile build-local.mk used by ndk-build will make some guesses about the location of the application makefile.

By default it seems the NDK is oriented towards having you stow your NDK application Application.mk and Android.mk files under a sub-directory called jni. This works nicely, and you can just use the command line:

$ ndk-build

If you don't want to have a jni sub-directory, for example, perhaps you're porting a linux command-line tool to Android, the following maybe appropriate for you:

Create an empty AndroidManifest.xml file

Now create an Application.mk file with the following contents:

APP_BUILD_SCRIPT := Android.mk

Then create an Android.mk file, for example:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := foo.c
LOCAL_MODULE := foo
include $(BUILD_EXECUTABLE)

To build the application use:

$ ndk-build NDK_APPLICATION_MK=`pwd`/Application.mk
于 2014-01-03T23:22:06.180 回答
17

您需要指定 3 件事。

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

需要这些来覆盖构建脚本的默认值,该脚本期望内容位于 jni 文件夹中。

调用 ndk-build 时使用

ndk-build NDK_PROJECT_PATH=/path/to/proj NDK_APPLICATION_MK=/path/to/Application.mk

在 Application.mk 添加

APP_BUILD_SCRIPT := /path/to/Android.mk
于 2015-04-06T12:08:36.273 回答
17
ndk-build NDK_APPLICATION_MK=path\to\your\src\main\jni\Application.mk NDK_PROJECT_PATH=path\to\your\module\src\main
于 2015-08-07T10:10:29.013 回答
13

这就是我使用的,cd进入项目目录并执行:

ndk-build NDK_PROJECT_PATH=.

在此处输入图像描述

于 2016-03-15T16:26:03.130 回答
4

请按照以下步骤操作:

1)Right on your project
2)Go to properties
3)Go to C/C++ Build
4)Go to Builder Settings
5)Go to Build Location
  Add build directory
6)Click on Workspace
7)Select your project folder

你应该看到类似的东西

${workspace_loc:/[Your Project_Name]}

完毕!!

于 2013-12-23T20:25:14.160 回答
3

这对我有用。没有环境变量,也没有设置。转到您在命令行上解压缩 ndk 的根目录并运行 ndk-build 命令:

ndk-build NDK_PROJECT_PATH=你的项目的路径

在我的开发机器中,示例如下所示:

 C:\adt-bundle-windows-x86-20140321\android-ndk-r9d>ndk-build NDK_PROJECT_PATH=D: /workspace/naruto  
 Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersi on 9 in D:/workspace/naruto/AndroidManifest.xml
 [armeabi] Compile thumb  : ndkfoo <= ndkfoo.c 
 [armeabi] SharedLibrary  : libndkfoo.so 
 [armeabi] Install        : libndkfoo.so => libs/armeabi/libndkfoo.so
于 2014-06-26T00:14:16.657 回答
3

-C为我工作。

在此处输入图像描述

您也可以使用 mac 终端来执行此操作。

于 2016-04-18T13:27:42.117 回答
2

您需要按照以下步骤操作:

1.转到包含Android.mk的文件夹

2.将android-ndk路径分配给$NDK_PROJECT_PATH。例如:导出 NDK_PROJECT_PATH =/home/android-ndk-r8b。

3. 将 NDK 添加到 $PATH。例如:导出 PATH=$PATH:/home/android-ndk-r8b。

于 2013-12-25T09:01:52.877 回答
0

设置您的 ndk builder 的工作目录可以解决您的问题,因为我遇到了同样的问题并以这种方式解决了它。

路径:项目属性 -> 构建器 -> -> 主目录 -> 工作目录

于 2013-11-25T04:02:42.667 回答