build_native.py not working for me

I just created my project with cocos command from terminal, when i try to build the game for android i got this below error.

Cocos2d-x version: 3.2
NDK version : 9
Mac OS x 10.10

and this is my .bash_profile:

export COCOS_CONSOLE_ROOT=/Users/sminrana/nonb/cocos2d-x/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

# Add environment variable ANDROID_SDK_ROOT for cocos2d-x
export ANDROID_SDK_ROOT=/Users/sminrana/nonb/adt/sdk
export PATH=$ANDROID_SDK_ROOT:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH

export NDK_ROOT=$ANDROID_SDK_ROOT/ndk
export PATH=$NDK_ROOT:$PATH

# Add environment variable ANT_ROOT for cocos2d-x
export ANT_ROOT=/Users/sminrana/nonb/apache-ant-1.9.2/bin
export PATH=$ANT_ROOT:$PATH

Error i got after running build_native.py

Android NDK: jni/…/…/cocos2d/external/chipmunk/Android.mk: Cannot find module with tag ‘platform/android’ 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:         
make: Entering directory /Users/sminrana/Games/ScreenCrackerMonsterX/proj.android' jni/../../cocos2d/cocos/./Android.mk:234: *** Android NDK: Aborting.    .  Stop. make: Leaving directory/Users/sminrana/Games/ScreenCrackerMonsterX/proj.android’
Traceback (most recent call last):
  File “./build_native.py”, line 159, in
    build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
  File “./build_native.py”, line 146, in build
    do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
  File “./build_native.py”, line 82, in do_build
    raise Exception(“Build dynamic library for project [ " + app_android_root + " ] fails!”)
Exception: Build dynamic library for project [ /Users/sminrana/Games/ScreenCrackerMonsterX/proj.android ] fails!

have you properly defined all the Environment Variables… !!

I doubt it… check again.
there are video tutorials on youtube

type sonar systems and go to cocos2d-x v3c++ tutorial series
and follow it.

Yes i think so. This is my NDK_MODULE_PATH

export NDK_MODULE_PATH=/Users/sminrana/nonb/cocos2d-x
export PATH=$NDK_MODULE_PATH:$PATH

I able to remove the error after deleting this line from ScreenCrackerMonsterX/cocos2d/cocos/Android.mk from line 234

$(call import-module,platform/android)

Now seeing another error, Any idea? I did something wrong?

 Android NDK: WARNING:jni/../../cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries    
make: Entering directory `/Users/sminrana/Desktop/ScreenCrackerMonsterX/proj.android'
[armeabi] Compile++ thumb: cocos2dx_static <= CCImage.cpp
jni/../../cocos2d/cocos/./platform/CCImage.cpp:63:10: fatal error: 'tiffio.h' file not found
#include "tiffio.h"
         ^
1 error generated.
make: *** [obj/local/armeabi/objs-debug/cocos2dx_static/platform/CCImage.o] Error 1
make: Leaving directory `/Users/sminrana/Desktop/ScreenCrackerMonsterX/proj.android'
Traceback (most recent call last):
  File "./build_native.py", line 159, in <module>
    build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
  File "./build_native.py", line 146, in build
    do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
  File "./build_native.py", line 82, in do_build
    raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
Exception: Build dynamic library for project [ /Users/sminrana/Desktop/ScreenCrackerMonsterX/proj.android ] fails!
Smins-MacBook-Pro:proj.android sminrana$ 

common … !! don’t delete anything which you don’t know what it works…

i am sure you’ve made backups for that file… :smile:
ok… to cut the long story and long time short… just go through the video tutorial atleast for the setup

do one thing at first.
go to the cocos2d-x folder i.e. the folder where you have the extracted files from the .zip of cocos2dx you’ve downloaded.

double click on setup.py
it will check all the environment variables are properly set or not.
if they are set… it will just close automatically, or else it will ask for
just go through the tutorial… you will find it helpful… :smile:

Yes i know there is a reason for that line to be in that file, i was just trying to see what happen without that line.

Did it again after cleaning everything. However setup.py does not include NDK_MODULE_PATH in my bash_profile. So we still have the error. I think something is missing from os x yosemite.

Now trying on ubuntu.

I think you need to run ./download-deps.py from your cocos install directory?

and what does it do @mannewalis . ??

the download-deps.py

@pabitrapadhy What should be the NDK_MODULE_PATH?

Anyone having such problem i suggest to use version 3.1.1 not 3.2. Version 3.2 does not work with OS X 10.10 Yosemite Beta. I’m using 3.1.1 on Yosemite beta and everything is working.

./download-deps.py downloads some dependencies that are needed when cloning from GitHUB. png, curl, etc.

You should have the following (similar) in .bash_profile

####################################
# Cocos2d-x and Android Development
###################################
# Cocos2d-x console
export COCOS_CONSOLE_ROOT=/Users/chukongus/Chukong-Inc/cocos2d-x-3.2/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

# Add environment variable NDK_ROOT for cocos2d-x
export NDK_ROOT=/Users/chukongus/Chukong-Inc/AndroidDev/android-ndk-r9d
export PATH=$NDK_ROOT:$PATH

# Add environment variable ANDROID_SDK_ROOT for cocos2d-x
export ANDROID_SDK_ROOT=/Users/chukongus/Chukong-Inc/AndroidDev/adt-bundle-mac-x86_64-20140321/sdk
export PATH=$ANDROID_SDK_ROOT:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH

# Add environment variable ANT_ROOT for cocos2d-x
export ANT_ROOT=/Users/chukongus/Chukong-Inc/AndroidDev/apache-ant-1.9.3/bin
export PATH=$ANT_ROOT:$PATH

I don’t have any problems with 3.2 on a certain unreleased operating system, that shall remain nameless since it is under NDA…

1 Like

i dont see a NDK_MODULE_PATH in my environment variables

there is NDK_ROOT

Everything is working fine on Android and iOS. NDK_MODULE_PATH was mentioned on the terminal when error occured.