PreBuilt Libraries, Android Studio & NDK_MODULE_PATH

PreBuilt Libraries, Android Studio & NDK_MODULE_PATH
0.0 0


More idiotic questions and intractable problems.

I am using @piotrros example ( to demonstrate using prebuilts with Android Studio. My cocos compile for studio is failing and it is because my NDK_MODULE_PATH is NOT getting set.

Has anyone any ideas where my problem might be??

My errors look like:
Building native…
NDK build mode: debug
running: ‘/Users/NF/SDK/android-ndk-r13b/ndk-build -C /Users/NF/MobDev/Cocos/ProjectName/ -j2 NDK_MODULE_PATH=/Users/NF/MobDev/Cocos/ProjectName/…/cocos2d:/Users/NF/MobDev/Cocos/ProjectName/…/cocos2d/cocos:/Users/NF/MobDev/Cocos/ProjectName/…/cocos2d/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1’

Android NDK: WARNING: Ignoring unknown import directory: /Users/NF/MobDev/Cocos/ProjectName/…/cocos2d
Android NDK: WARNING: Ignoring unknown import directory: /Users/NF/MobDev/Cocos/ProjectName/…/cocos2d/cocos
Android NDK: WARNING: Ignoring unknown import directory: /Users/NF/MobDev/Cocos/ProjectName/…/cocos2d/external
Android NDK: jni/ Cannot find module with tag ‘./prebuilt-mk’ in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?

My jni/

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyGame_shared
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_STATIC_LIBRARIES := cocos2dx_static
#$(call import-module,.)
$(call import-module,./prebuilt-mk)

My build.gradle:

apply plugin: ‘’
android {
compileSdkVersion 23
buildToolsVersion “23.0.3”
defaultConfig {
applicationId “org.cocos2dx.ProjectName”
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName “1.0”
ext {
externalNativeBuild {
ndkBuild {
targets “MyGame”
arguments “NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk:$cocospath/extensions”
arguments “-j” + Runtime.runtime.availableProcessors()
abiFilters “armeabi”
// available abiFilters (for debugging):
// abiFilters “x86”, “armeabi”, “armeabi-v7a”, “arm64-v8a”
sourceSets.main {
java.srcDir “src”
res.srcDir “res”
jniLibs.srcDir “libs”
manifest.srcFile “AndroidManifest.xml”
assets.srcDir “assets”
externalNativeBuild {
ndkBuild {
path “jni/”
signingConfigs {
release {
if (project.hasProperty(“RELEASE_STORE_FILE”)) {
storeFile file(RELEASE_STORE_FILE)
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘’
if (project.hasProperty(“RELEASE_STORE_FILE”)) {
signingConfig signingConfigs.release

dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
compile project(’:libcocos2dx’)

task cleanAssets(type: Delete) {
delete ‘assets’
task copyAssets(type: Copy) {
from ‘…/…/Resources’
into ‘assets’

clean.dependsOn cleanAssets
preBuild.dependsOn copyAssets


Why won’t you run project from Android Studio directly?

I just tried running from console and:

The android command is no longer available.


But it works from Android Studio.


Hi @piotrros

It is failing to compile ‘cocos compile -p android -m debug --android-studio’ with this problem with NDK_MODULE_PATH. Any ideas? (Not tried to ‘cocos run…’ yet)

I have opened the main ProjectName folder in Android Studio (AS) and everything looks Ok, I can see the C++ files. I can ‘Build -> Make Module ‘ProjectName’’.

When I try to ‘Run -> Debug’ the system requests I ‘Edit Configuration…’. When I create a new (debug) configuration I select ‘Android App’ but then I am unable to select a ‘Module’…

  1. So I am unable to ‘cocos compile…’ because of some NDK_MODULEPATH problem…
  2. I seem unable to debug from AS because I do not know how to create a suitable module when I open your ‘ProjectName’ folder/project in AS…

Apologises for asking coming back with issue after issue. :confounded:


You don’t have to create it by yourself. AS should automatically do this. Do you open directly? It should like this:


Thought I had this fixed. Unpacked your ProjectName project and updated settings for my environment. Imported to Android Studio and everything looked Ok.

Tried to debug on my device and got these errors. Looks like the build is trying to build my cocos2d-x source files in some strange ‘…/editor-support/…’ directory, see below. Any clues, thanks?


Can you switch from Project to Android on the left?

Do you build precompiled libraries like this?:

cocos gen-libs -p android --app-abi armeabi-v7a

Also make sure android studio is using ndk r13b.


Hi @piotrros, yes I can switch - see below. I built the precompiled libraries for all targets x86, armeabi & armeabi-v7a and, yes, currently using ndk r13b.

Still ‘seeing’ the C++ compile error. Think I shall give up on this until cocos2d-x 3.15.

Thanks for the support offered.


Downloaded the second sample project above and set it up and this is the error message i get, any ideas?

Error while executing process C:\Users\Genesis\AppData\Local\Android\sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Genesis\Desktop\ProjectName\\app\jni\ NDK_APPLICATION_MK=C:\Users\Genesis\Desktop\ProjectName\\app\jni\ APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-9 NDK_OUT=C:/Users/Genesis/Desktop/ProjectName/ NDK_LIBS_OUT=C:\Users\Genesis\Desktop\ProjectName\\app\build\intermediates\ndkBuild\release\lib NDK_MODULE_PATH=C:/Cocos/frameworks/cocos2d-x-3.10:C:/Cocos/frameworks/cocos2d-x-3.10/cocos:C:/Cocos/frameworks/cocos2d-x-3.10/external:C:/Cocos/frameworks/cocos2d-x-3.10/cocos/prebuilt-mk -j8 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}


So you’re using Windows. In that case you cannot use “:” as path separator.
Instead use “;” like this:

arguments "NDK_MODULE_PATH=$cocospath;$cocospath/cocos;$cocospath/external;$cocospath/cocos/prebuilt-mk"

also make sure all paths are correct.


Changed it and some of the errors went away and these stayed.

Error:(32) *** Android NDK: Aborting. . Stop.
Error:A problem occurred configuring project ‘:ProjectName’.

executing external native build for ndkBuild C:\Users\Genesis\Desktop\ProjectName\\app\jni\

also i do not have a prebuilt-mk at all, I have searched online and locally for it but do not have one.


It seems like you’re using too old cocos version. You need at least 3.14.1. Also: did you generate prebuilt libs?


downloaded 3.14,the reason i was using 3.10 is because i use cocos studio and i am already too far in to swap. I recall you saying in an another post that its possible to use 3.14 for cocos studio, can you tell me how?


Well it just works for me. There are still classes to read Cocos Studio scenes in cocos2d-x 3.14 code.