NDK can't find the application directory

2019-01-21 04:30发布

When running the ndk-build command I get the following error:

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

The contents of my Android.mk file:

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)

Adding the following line doesn't help:

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

11条回答
The star\"
2楼-- · 2019-01-21 04:59

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
查看更多
家丑人穷心不美
3楼-- · 2019-01-21 05:00
ndk-build NDK_APPLICATION_MK=path\to\your\src\main\jni\Application.mk NDK_PROJECT_PATH=path\to\your\module\src\main
查看更多
我命由我不由天
4楼-- · 2019-01-21 05:00

This is what I use, cd into the project directory and do:

ndk-build NDK_PROJECT_PATH=.

enter image description here

查看更多
老娘就宠你
5楼-- · 2019-01-21 05:00

This worked for me. No environment variables and no setups. Go to the root directory where you unzipped ndk on command line and run ndk-build command:

ndk-build NDK_PROJECT_PATH=path to your project

A sample would look like this in my dev machine:

 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
查看更多
乱世女痞
6楼-- · 2019-01-21 05:01

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
查看更多
成全新的幸福
7楼-- · 2019-01-21 05:02

Follow Below steps:

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

you should see something like

${workspace_loc:/[Your Project_Name]}

Done!!

查看更多
登录 后发表回答