cocos2d-x-2.2.5 setup guide

I can’t agree more. I’ll share whatever I can on the topic. My only reference is a book covers 2.0.x and there is much different approaches in regards to setup. 2.2.5 feels like it is caught between the original 2.0 and 3.0 in regards to setup. I can see the cleaner projects, vision, and better scripts forming. But I have to kind of figure out how it works in this in between state. I am putting it together piece by piece. I can compile, and push to device, it wont run (missing a library still.) But I am slogging through the errors. Its taken some time. Going to 3.0 is a bridge too far this time or I would just go all the way.

Thanks for all the support!!! You guys are great. I hope I am not being to much of a pest. :wink:

The README.md in the created projects folder is clearer now except for what target to use (step 6? wth is step 6, so I think that is likely a left over bit from older docs.)

What version of the NDK was this tested with? I found myself using 10b (64bit) I got the 32 bit versions (non beta) to try out. Should I not use latest? Did I miss this requirement somewhere? To get the HelloWorld sample app to run (well run into the current error I am having with all projects) I had to combine the 32 bit and overlay/overwrite with the 64 bit version. This is because of the “android-L” headers? I don’t know anything about this so I wont pretend too, but “rand()” was missing of all things. Soooo that fixed that issue. (here was where I found the hint)

For the morbidly curious this is the current error I am working through:
09-17 14:54:49.010: E/AndroidRuntime(25032): java.lang.UnsatisfiedLinkError: Couldn’t load testcpp from loader dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/org.cocos2dx.testcpp-1.apk”],nativeLibraryDirectories=[/data/app-lib/org.cocos2dx.testcpp-1, /vendor/lib, /system/lib]]]: findLibrary returned null

If you know what causes this let me know. I am looking at what files got stuck where on the device… but there is a voice in the back of mind that says I shouldn’t have to if everything was configured right!

I seriously think I have something horribly wrong in my setup. I am going to to just start over. or try on other machines/devices. it simply can’t be this hard…

Well there seems to be a documentation, but that is only API reference. No tutorials that show actual usage of the code snippets. Like how to create a project, use tilemaps, etc.

1 Like

Using ADB I have ascertained that /data/data/org.cocos2dx.hellocpp/lib/libhellocpp.so does not exist on device after running “ant debug install” and all the samples fail this way now as does my created projects. so I am focusing there. Clearly a case of “I am missing something, but I don’t have a clue where” scenario. An app shows up in the application list on device, but I presume it is failing because it can’t find the expected files.

From within the ADB shell:

    1|root@android:/ # ls /data/data/org.cocos2dx.hellocpp                     
    /data/data/org.cocos2dx.hellocpp: No such file or directory

Thanks for everyones support on this. You guys have been if anything encouraging me to continue running myself at the wall. I will break through. It is what I do. :wink:

UPDATE:
Well I scrubbed every line of the output from ant debug install and I noticed this little message:

debug:

install:
     [echo] Installing /Users/hunter/Appsomniacs/cocos2d/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/bin/TestsDemo-debug.apk onto default emulator or device...
     [exec] 3874 KB/s (88110811 bytes in 22.210s)
     [exec] 	pkg: /data/local/tmp/TestsDemo-debug.apk
     [exec] Failure [INSTALL_FAILED_CONTAINER_ERROR]

So I suspect INSTALL_FAILED_CONTAINER_ERROR is bad?

UPDATE 2:
I finally just started over followed the README.md for Eclipse to the ‘T’
I got the same errors. (I noticed a warning in eclipse about not being able to find an include directory in the NDK. The only thing in NDK_ROOT/platforms/ folder was ‘android-L’. I had read about this somewhere.

I rolled back to use NDK 10 (32 bit):
I got a compile error about missing ‘rand()’ again, in the past I had put in the 32 bit version and copied over the 64 bit version replacing anything and that worked. but I didn’t want to spend the time, so I don’t know if that would solve the issue.

I rolled back to NDK 9d
It worked for HelloCPP

Bottom line, the terse README.md that is in every created project has the steps (I will try the command line later, as I prefer it at times, but I got the same errors in eclipse as command line. just remember to clean if you use eclipse and go command line to remove the ‘crunch’ directory.)

I am not out of the woods yet, but with the basics working then I can get this into the shape the team wants (in a different folder structure external to cocos2d, etc.)

if you’ve read this far. Good on you. you’ve got stamina. I hope this helps someone int he future. Or if starting new go check out v3.x+ first.

tl:dr 2.2.5 setup summary of the solution that worked for me (gory details of failures are in previous posts in this thread.)

1) Get the cocos2d-x 2.2.5 download and unpack it somewhere, same with the ADT tools (the android SDK and Eclipse)

2) Use ndk 9d (ensure that your target platform is present(e.g., as 9/18/2014 10b only has ‘android-L’ as a valid target. Put of the box I was targeting android-8 [i.e. Android 2.2])

3) use the existing projects (helloworldCpp and TestCpp) or create a project using the supplied python script the {cocos2d_root}/tools/project-creator directory:
user$ python create_project.py -project AppTest -package com.appsomniacs.test -language cpp

4) follow the instructions in the README.md that every new project has in it’s {project root}/proj.android folder that is made with create_project.py

5) Profit.

NOTE: If you get the following error…

../../../..//extensions/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.cpp:54:9: error: 'transform' is not a member of 'std'
make: *** [obj/local/armeabi/objs/cocos_extension_static/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.o] Error 1

add:

#include <algorithm>

to {cocos2d-x-2.2.5 root}/extensions/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.cpp
I think this is just missing from the 2.2.5 distro as noted in this answered question: http://stackoverflow.com/questions/24848923/error-after-building-a-testcpp-eclipse-project

If you use the latest from git i am not sure if this is fixed in their yet, but there has been a lot of activity there too.

@GMTDev thanks for the reminder about HAXM. I had accidentally picked an x86 supported target to build to device (which happened to be x86) but was quickly reminded that not all simulator images are the same when I tried to build to the simulator without getting and x86 supported target!

this is link to download Android NDK r9d:
https://drive.google.com/file/d/0B9Cf3noETTlrVEFtaF9LUjFhT00/edit?usp=sharing

1 Like

Could somebody tell me which version of cocos studio files will work with cocos2d-x-2.2.5?
I’ve been trying to load the files exported by cocosstudiov1.0 beta (MAC) but it keeps crashing because format is not what the reader is expecting.