Cpp-test on Android problems (terminal)

Hi,
I’m new to cocos2dx so I decided to go through the guide and the wiki.

I didn’t get it how to run cpp-tests on android (eclipse) [How to run cpp-tests on Android (Eclipse)][1] [1]: http://cocos2d-x.org/wiki/How_to_Build_an_Android_Project_with_Eclipse

So i decided to try to run cpp-tests on android (terminal) [How to run cpp-tests on Android (Terminal)][1] [1]: http://cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android

I made it to set up cocos2dx with all environmental variables (and yes I used the ndk version r9d)
but now as I wanted to follow the instructions

Now I can execute:

python android-build.py -p 19 cpp-tests

That’s it! The script will handle everything else that you need. When finished you should get the following message:

I got the following error code:

Can not be determined your ndk version
NDK_TOOLCHAIN_VERSION is 4.8, your application may crash on Android when use c++ 11 regular

I’m not sure what to do now. Could anybody help me.

I really want to start with cocos2dx :smiley:

By the way is there a tutorial that explains how to set up a project in eclipse with cocos2dx and how to use cocos2dx (not things like sprites and so on, but where to put the code in the project and what to do to get the project running)

Check this video series
http://discuss.cocos2d-x.org/t/education-platform/18226
Also check programmers guide

1 Like

You probably need to run setup.py

@sayedtdm Yes, thank you for the answer.
That’s exactly what I did before I described my issues here. I tried to follow the instructions of the video again, but at the point where I have to call build_native.py there’s another error.

Couldn’t find the gcc toolchain

@mannewalis I did that already as it was desribed in the video

Can you give more details about version you are using and environment you have?
Did you try cocos console? like $cocos run -p android

I am using:

  • windows 8.1 64-bit
  • eclipse Luna
  • Python 2.7.9
  • apache ant 1.9.4
  • android ndk r9d
  • android sdk (not sure how to check version)
  • cocos2dx v3.3
  • what else ?

When I run cocos run -p android in the cpp-empty-test directory theres the following error

Can’t find right android-platform for project “…\cpp-empty-test\proj.android”. The android-platform should be equal/larger than 10

You can use android tool in SDK folder to determine installed versions of API’s
You can use the following commands to update your project settings to API 19 for example:

android list targets
android update project -p proj.android/ -t android-19
android update project -p /cocos2d/cocos/2d/platform/android/java/ -t android-19

But how do I handle all these errors?

  1. post

Can not be determined your ndk version
NDK_TOOLCHAIN_VERSION is 4.8, your application may crash on Android when use c++ 11 regular

  1. post

Couldn’t find the gcc toolchain

  1. post

Can’t find right android-platform for project “…\cpp-empty-test\proj.android”. The android-platform should be equal/larger than 10

Now it doens’t show the error anymore. It changed to:

Can’t find right android-platform for project “…\cpp-empty-test\proj.android”. The android-platform should be equal/larger than 19

By the way the error of the third post and this one both start with

Running command: compile
Building mode: debug
Android platform not specified, searching a default one …

I checked the sdk path and changed it to the right one (where the versions are already installed)

Then I tried to solve this error by adding --ap android-19 ( [stackoverflow solution][1] )
[1]: http://stackoverflow.com/questions/23551144/cocos2d-x-doesnt-find-android-platform

Now I get the following error message (shortened):

Error: Argument ‘cocos\TutorialV3CPPWindows\proj.android’ is not recognized.

Error: Argument ‘cocos\TutorialV3CPPWindows\proj.android…/cocos2d/cocos/platform/android/java -t android-19’ is not recognized.

NDK_TOOLCHAIN_VERSION: 4.8
running: ‘D:\Programme\android-ndk-r9d-windows-x86\android-ndk-r9d\ndk-build -C
D:\workspace cocos\TutorialV3CPPWindows\proj.android -j8 NDK_MODULE_PATH=D:\work
space cocos\TutorialV3CPPWindows\proj.android…/cocos2d;D:\workspace cocos\Tuto
rialV3CPPWindows\proj.android…/cocos2d/cocos;D:\workspace cocos\TutorialV3CPPW
indows\proj.android…/cocos2d/external NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=1’

make.exe: *** D:\workspace: No such file or directory. Stop.
Ndk build failed!

I tried now again to run

python android-build.py -p 19 cpp-tests

I get a lot of things that look like this

[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCVertexIndexBuffer.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCVertexIndexData.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCPrimitive.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCPrimitiveCommand.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCTrianglesCommand.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCArray.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCSet.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCString.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCDictionary.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCDeprecated.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCNotificationCenter.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCPhysicsBody.cpp
[armeabi] Compile++ thumb: cocos2dx_internal_static <= CCPhysicsContact.cpp
In file included from D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\../cocos/re
nderer/CCRenderCommand.h:31:0,
                 from D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\../cocos/re
nderer/CCTrianglesCommand.h:28,
                 from D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\../cocos/re
nderer/CCTrianglesCommand.cpp:25:
D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\../cocos/renderer/CCTrianglesComm
and.cpp: In member function 'void cocos2d::TrianglesCommand::init(float, GLuint,
 cocos2d::GLProgramState*, cocos2d::BlendFunc, const cocos2d::TrianglesCommand::
Triangles&, const cocos2d::Mat4&)':
D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\../cocos/platform/CCPlatformMacro
s.h:222:67: warning: format '%zd' expects argument of type 'signed size_t', but
argument 2 has type 'ssize_t {aka long int}' [-Wformat=]
 #define CCLOGERROR(format,...)  cocos2d::log(format, ##__VA_ARGS__)
                                                                   ^

but at the end it fails

At global scope:
cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat" [e
nabled by default]
[armeabi] StaticLibrary  : libcocostudio.a
[armeabi] StaticLibrary  : libcocosbuilder.a
[armeabi] StaticLibrary  : libcocos3d.a
[armeabi] StaticLibrary  : libspine.a
[armeabi] StaticLibrary  : libnetwork.a
[armeabi] StaticLibrary  : libaudioengine.a
[armeabi] StaticLibrary  : libui.a
[armeabi] StaticLibrary  : libcocosdenshion.a
[armeabi] StaticLibrary  : flatbuffers.a
[armeabi] StaticLibrary  : libextension.a
[armeabi] StaticLibrary  : libcocos2dxinternal.a
[armeabi] StaticLibrary  : libbox2d.a
[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] StaticLibrary  : libcocos2dandroid.a
[armeabi] SharedLibrary  : libcpp_tests.so
[armeabi] Install        : libcpp_tests.so => libs/armeabi/libcpp_tests.so
make.exe: Leaving directory `D:/Programme/cocos2d-x-3.3/cocos2d-x-3.3/tests/cpp-
tests/proj.android'
Der Befehl "D:\Programme\Android" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
update cocos lib-project [ D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\..\coc
os/platform/android/java ] fails!

you need to be on ndk-r10c for version 3.3

Thank you I’ll try it. I just read everywhere: take the version r9d. I didn’t know that you have to use the newer version for cocos2dx 3.3

Now the message is vastly smaller

D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build>python android-build.py -p 19 cpp
-tests
We will use cocos console to build tests built-in with cocos2d-x and remove this
 script next version.

D:\Programme\android-ndk-r10c\ndk-build -j8 NDK_DEBUG=1 NDK_MODULE_PATH=D:\Progr
amme\cocos2d-x-3.3\cocos2d-x-3.3\build\..;D:\Programme\cocos2d-x-3.3\cocos2d-x-3
.3\build\../external;D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\../cocos NDK
_TOOLCHAIN_VERSION=4.9 -C D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\..\test
s/cpp-tests/proj.android
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersi
on 9 in ./AndroidManifest.xml
make.exe: Entering directory `D:/Programme/cocos2d-x-3.3/cocos2d-x-3.3/tests/cpp
-tests/proj.android'
[armeabi] Gdbserver      : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[armeabi] Install        : libcpp_tests.so => libs/armeabi/libcpp_tests.so
make.exe: Leaving directory `D:/Programme/cocos2d-x-3.3/cocos2d-x-3.3/tests/cpp-
tests/proj.android'
Der Befehl "D:\Programme\Android" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
update cocos lib-project [ D:\Programme\cocos2d-x-3.3\cocos2d-x-3.3\build\..\coc
os/platform/android/java ] fails!

but it still fails

Trying to follow the instructions of the tutorial video the only changes are that it says
NDK toolchain version was 4.9 !

The Selected NDK toolchain version was 4.8 !
make.exe: *** D:\workspace: No such file or directory. Stop.
Traceback (most recent call last):
File “D:\workspace cocos\TutorialV3CPPWindows2\proj.android\build_native.py”,
line 149, in
build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
File “D:\workspace cocos\TutorialV3CPPWindows2\proj.android\build_native.py”,
line 134, in build
do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and
roid_platform,build_mode)
File “D:\workspace cocos\TutorialV3CPPWindows2\proj.android\build_native.py”,
line 70, in do_build
raise Exception(“Build dynamic library for project [ " + app_android_root +
" ] fails!”)
Exception: Build dynamic library for project [ D:\workspace\ cocos\TutorialV3CPP
Windows2\proj.android ] fails!

And I found the mistake: I used a space in the name of the folder now it compiles. Worked!

Good. Glad it works. We should edit the guide to state no spaces in the path and file a bug as well so we can accommodate spaces, somehow.

I have problem while trying to create project:
“cocos new: error: one of the arguments -l/–language --list-templates -k/–template-name is required”

what command did you execute?

cocos new MyGame -p com.whatever.mygame -l cpp -d <path to where you want it created>

This “cocos new Flappy -p learning.avante.Flappy -1 cpp -d /Users/Avante2/Desktop/Flappy”

It’s not the number -1(one), but the letter -l([ʔɛl]).

Thanks very much really appreciate ur help mate

Hi guys following the tutorial for flaby bird up to tut 3 when i create a SplashScene Screen it wont find the png picture and doesnt load it:

What tutorial?

it looks like you code you are calling Splash Screen.png but looking to the left in Resources/ipadhd/ yoh have that file name different. Also, best to not use spaces.

1 Like