I am trying to create a module with the Android NDK, but I can't seem to get the build program to take the path variable. I have tried setting it as an environment variable in cygwin:
$ echo $NDK_MODULE_PATH
/cygdrive/c/dev/code/git/android_source
I also specify it within the Android.mk file:
#===================================
LOCAL_PATH:= $(call my-dir)
NDK_MODULE_PATH := $(LOCAL_PATH)/../../code/git/android_source/
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := user
LOCAL_MODULE := libFilters
LOCAL_SRC_FILES := SkewFilter.cpp SkewFilter.h
LOCAL_LDLIBS := -llog
LOCAL_EXPORT_LDLIBS := -lz
LOCAL_SHARED_LIBS := libskia
include $(BUILD_SHARED_LIBRARY)
#===================================
$(call import-module,libskia)
The end result is still this:
$ ndk-build
Android NDK: jni/Android.mk: Cannot find module with tag 'libskia' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
jni/Android.mk:17: *** Android NDK: Aborting. . Stop.
Anyone have any idea of what I'm doing wrong?
I found this question How to specify directory for NDK_MODULE_PATH but it wasn't any help.
I figured out what I was doing wrong. This line in the Android.mk file needs to change from:
$(call import-module,libskia)
to
$(call import-module,external/skia)
It doesn't do a recursive search for the module so when calling import-module it needs the full path relative to your NDK_MODULE_PATH (NDK_MODULE_PATH + path_to_module).
The error message that ndk-build prints seems to be wrong since it doesn't list any paths in the NDK_MODULE_PATH variable, but they are there and it uses them.
Hope this helps someone else.
Related
I'm new to this NDK build and I'm having trouble with running this Buildbox project in android studio.
After linking C++ to Gradle using ndk-build and syncing, it is giving this error.
Android NDK: C:\AndroidApps\app\app\src\main\jni\Android.mk: Cannot find module with tag 'box2D' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined?
Android NDK: The following directories were searched:
Android NDK:
process_begin: CreateProcess(NULL, "", ...) failed.
I can see reference for cocos2dx in the java and resources subfolders.
I'm not sure if I have to download box2D,core,cocos2dx library .
What changes do I have to make to the android.mk file so that the errors are gone?
Here is the android.mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := player_shared
LOCAL_MODULE_FILENAME := libplayer
LOCAL_SRC_FILES := main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := core_static cocos2dx_static box2d_static
GOOGLE_PLAY_STORE := true
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, $(LOCAL_PATH)/platform/third_party/android/prebuilt)
$(call import-module, box2D)
$(call import-module, core)
$(call import-module, cocos2dx)
NDK does not download imported modules for you. I am not sure if there are plans to add such feature (parallel to XCode pods) in the future.
You will find detailed description of import-module here, but basically you can set NDK_MODULE_PATH in your Application.mk file, with ; separators on Windows, but using straight / in paths instead of Windows native backsashes, e.g. C:/ext), and then
$(call import-module, box2D)
will be equivalent to
include C:/ext/box2D/Android.mk
I am trying to use android-ndk-profiler - https://github.com/richq/android-ndk-profiler
As described in the usage document https://github.com/richq/android-ndk-profiler/blob/master/docs/Usage.md
I unzipped the zip file to $HOME/Documents/Dev
My Android.mk looks like this
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndkbasics
LOCAL_SRC_FILES := ndkbasics.cpp
LOCAL_LDLIBS := -llog
# compile with profiling
LOCAL_CFLAGS := -pg
LOCAL_STATIC_LIBRARIES := android-ndk-profiler
include $(BUILD_SHARED_LIBRARY)
# at the end of Android.mk
$(call import-module,android-ndk-profiler)
When trying to build using the command
ndk-build NDK_MODULE_PATH=$HOME/Documents/Dev/
I get the error
Android NDK: /Users/hanantha/Documents/Dev/projects/workspaceWeeklyPreso/NdkProfileMethods/jni/Android.mk: Cannot find module with tag 'android-ndk-profiler' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
/Users/hanantha/Documents/Dev/projects/workspaceWeeklyPreso/NdkProfileMethods/jni/Android.mk:16: *** Android NDK: Aborting. . Stop.
Additional points
I have tried setting NDK_MODULE_PATH in my bash_profile
ndk version r10d
Ran the make file in the unzipped folder android-ndk-profiler
It is strange that ndk says the directories that it has searched is empty. What could be going wrong?
I think you have done almost correct process need to change at one place as follow
# at the end of Android.mk
$(call import-module,android-ndk-profiler/jni)
Adding jni in import-module will solve your problem because it's working for me.
i'm trying to build a setup for game development(android) using VisualGDB and cocos2d-x.
My problem is when i create a project using Third party library(Cocos2d-x) in VisualGDB i get the error "Toolchain test failed:cannot query the value of Target_cxx"
If i ignore it and create project then after compliling i get the following error:
I have searched a lot allover the internet but nothing actually helped me. All i got is that i have to set some NDK_BUILD path in my Android.mk file
Here is my Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
#VisualGDBAndroid: AutoUpdateSourcesInNextLine
LOCAL_SRC_FILES := AppDelegate.cpp hellocpp/main.cpp HelloWorldScene.cpp ../main-win32.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
LOCAL_STATIC_LIBRARIES := cocos2dx_static
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
#VisualGDBAndroid: VSExcludeListLocation
VISUALGDB_VS_EXCLUDED_FILES_Debug__Android_ := ../main-win32.cpp
LOCAL_SRC_FILES := $(filter-out $(VISUALGDB_VS_EXCLUDED_FILES_$(VGDB_VSCONFIG)),$(LOCAL_SRC_FILES))
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END
Ps: when i create a simple android project(not with cocos2d-x) using visualGDb then there is no error.
Can any one please help me on this?
There is no need to set ndk_build path in the android.mk file. You can do the same by two ways:
1.To build cocos2dx projects for android, you need to set 3 environment variables NDK_ROOT, ANDROID_SDK_ROOT and ANT_ROOT.
I use MAC OS to build projects and i do the above through command line as follows:
export NDK_ROOT="/Users/Rajeev/Documents/AndroidDev/android-ndk-r10c"
You can search for the same how to do on windows.
2.Cocos2dx also provides its setup.py, a python script. If you run the script it will ask you all the above 3 paths and there will be no need to define them later.
Hope it will help.
You should set your system environment variables and add NDK_ROOT to point to your Android NDK path. Take a look at this page and try to add NDK_ROOT to your system environment variables.
I realise this question has been asked before but no answers have been able to solve my problem.
I'm trying to build a sample android app provided with NDK which has the following Android.mk file:
LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_PATH)
LOCAL_MODULE := native-activity
LOCAL_SRC_FILES := main.c
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
When I build my project I get the follow error:
**** Build of configuration Default for project NativeActivity ****
/Users/Jono/Documents/Development/Android Development/android-ndk-r9c/ndk-build all
usage: dirname path
make: /Users/Jono/build/core/build-local.mk: No such file or directory
make: *** No rule to make target `/Users/Jono/build/core/build-local.mk'. Stop.
**** Build Finished ****
The problem is that it is looking for build files in my root directory, but I'm not really sure what its doing, what files it looking for, where it should be looking and then what I should do to fix it.
You should not use space in your path to NDK. Change the folder name "Android Development" to something with no white space, i.e. "AndroidDevelopment".
NDK may get very unhappy when the directory names have spaces, as your Android Development. Simply rename the directory to Android_Development, and don't forget to update the ADT preferences.
I am new to using NDK platform and I get the following error on running ndk-build in the terminal:
aditya#aditya-Vostro1510:~/workspace/Fibonacci$ ~/android-ndk-r9/ndk-build
Android NDK: WARNING: APP_PLATFORM android-18
is larger than android:minSdkVersion8 in ./AndroidManifest.xml
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk
/home/aditya/android-ndk-r9/build/core/add-application.mk:176: *** Android NDK: Aborting... . Stop.
I didnt make an application.mk file as I read it was optional and the video tutorial I refered did not include it too.
android.mk contains foll code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := com_Native_fibonacci_fiblib.c
LOCAL_MODULE := com_Native_fibonacci_fiblib
include $(BUILD_SHARED_LIBRARY)
I tried searching for help on forums but failed.Please give me a detailed solution for this.