Need help getting started with Cocos2d-x to build for iOS & android

Thanks… I’ll look towards unity… will see what is worse. Damn, when I developed games for iOS only using cocos2d-iphone it was so nice so simple. Also when apportable was alive I was able just in magical and simple way port my game to android by just build and run in xcode… But as I see with cocos2d-x it’s so hard and awkward… okay\ Also it’s bad that you don’t understand how kind documentation should be… I think many people now trying using free cocos2d-x and then at starting puzzle stage - just make it work - just go away in searching some better solutions like unity… to bad.

We hear this from time to time for sure. We don’t cover in great detail the things that Apple and Google are already covering. Perhaps we could add more links to our docs to see external resources for help, but these links change and we spend time chasing down where the content moved to.

p.s. I just tried to build iOS project in Xcode, before that I just opened project and don’t tried to build it, because my main target is android. However it’s not compiling -

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_CCEAGLView", referenced from:
      objc-class-ref in RootViewController.o

iOS libs were created in debug mode.
lol… what I can say more? Ahh…
Everything I did was with problematic, almost any step. You know what all feeling in general about engine now? For sure not to use it…

I’m sorry that this is your experience. I can say honestly that an experience like this is not common for us

Are you using v3.13.1?

So you downloaded the .zip from the website?

cocos gen-templates…

cocos gen-libs…

cocos new … -t binary

Open the project in Xcode and this error occurs when compiling?

What about if you run: cocos run …

I use cocos2d-x 3.10 (mod curl), i can say the easiest way to use it:
Install cocos2dx, install cocos studio.
Set everything (NDK, SDK, whatever)
Create a project from cocos studio.
iOS run and general develop use XCode.
If you need android run, compile, use command line.
For APK Signing (and only for that) i use Android Studio.
If you need specific android debug, import project to eclipse (don’t forget to import sources, and libs, like google admob), set Android xml debug=true,
and voila, it works correctly with breakpoints, etc.

And the best tutorial:

This simple part takes for me many time and running setup.py was always unsuccessful, because even I paste folder to NDK and SDK - it’s saying that it’s wrong path same problem as here http://stackoverflow.com/questions/27773111/set-up-cocos2d-x-for-android-on-mac

I’m using latest, as described in 1st post. Thanks for this thread - Prebuilt libraries setup the definitive guide and game project kickstart for cocos2d-x 3.13.1
I can now build and run for iOS only. So one of the problems was that in cocos2d-libs project option for build active libs only in debug was set to YES, but it should be NO, so in debug all architectures will be build for iOS.
In release mode it’s set to NO and my project runs. Also other problems was there like this:

So many things to fix many hours to struggle with just installation and build.\

Now, I want to find any friendly example or tutorial: how to build, run and publish game to android. With lets say real life examples. Also I need of course to debug project as I’m doing so in Xcode for iOS, ah so amazing platform pleasure to work with. So what android gives instead?

“Now, I want to find any friendly example or tutorial”
On *nix systems is not so easy if you don’t have a little experience with paths, rights, etc.
Because every setup is individual.
But it’s not hard.

" Set everything (NDK, SDK, whatever)
This simple part takes for me many time and running setup.py was always unsuccessful"
I set up my environment with this tutorial:
http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android

For example by me the .bash_profile file looks like this (maybe there is some incorrect setting in, but it works):
# ANDROID DEVELOPMENT
export PATH="/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/AndroidDev/android-sdk-macosx/tools:$PATH"
export PATH="/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/AndroidDev/android-sdk-macosx/platform-tools:$PATH"
export PATH="/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/AndroidDev/apache-ant-1.9.4/bin:$PATH"
export PATH="/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/AndroidDev/android-ndk-r10e:$PATH"

# ANDROID DEVELOPMENT
export JAVA_HOME=$(/usr/libexec/java_home)
export NDK_ROOT="/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/AndroidDev/android-ndk-r10e"
export ANDROID_SDK_ROOT="/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/AndroidDev/android-sdk-macosx"
export ANT_ROOT="/Applications/Cocos/tools/ant/bin"

# Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x
export COCOS_CONSOLE_ROOT=/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/cocos2d-x-3.10/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

# Add environment variable COCOS_TEMPLATES_ROOT for cocos2d-x
export COCOS_TEMPLATES_ROOT=/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS/cocos2d-x-3.10/templates
export PATH=$COCOS_TEMPLATES_ROOT:$PATH

# Add environment variable COCOS_FRAMEWORKS for cocos2d-x
export COCOS_FRAMEWORKS=/Applications/Cocos/Cocos2d-x
export PATH=$COCOS_FRAMEWORKS:$PATH

# Add environment variable COCOS_X_ROOT for cocos2d-x
export COCOS_X_ROOT=/Volumes/Data/Users/XXXUSERXXX/CODE-IPOD/DEV_LIBS
export PATH=$COCOS_X_ROOT:$PATH

Thanks, but mine was good too. But setup ignored my path for SDK some reason, I don’t have any clue why. TOday, after 3 days of problems I finally set up all things just to create a simple project and compile it for iOS, not sure about android yet. I just staring to do that. First will see if libs will compile and then project.

upd.: today for some reason can’t compile lib for iOS error 65. I just created project without libs…

maybe you need restart after bash_profile :smiley:

Lol nope, I restarted it many times because I already struggle with this 3 days.
So now where I can find a simple tutorial or doc that shows how on macOS build & run android project and see finally actual result, like working scene?

I found that Android Studio IDE is what I need? Any example or doc about that?

I use xcode.

Google, Cocos2d-x docs, SonarLearning, etc

I need cocos2d-x only for android. So how I build my game for android in Xcode? I really waned to.

I’m using CocosBuilder(aka SpriteBuilder) and really happy with coding for iOS. So simple, fast and comfortable. So, for android I will export levels in xml and load them in cocos2d-x and build for android, thats what I need.

I searched but a lot of info looks outdated and many people talking about pre-release options for android studio…

Cocos2d-x docs is awkward, this topic actually about that. But where is in them some information and example how to build game for android in Android studio and finally see running scene anywhere?

SonarLearning - there is no such example for android studio to build or something.

For android i use console.
If need some android spec debug, then eclipse.
Android studio i use only for signing key generation, not more.

But I would need to add specific SDK’s for android,in-apps and game center. I’m looking for some IDE for that. So this should be Eclipse? And I should use another IDE just for signing?

In eclipse i add for example admob.
For signing you don’t need any IDE. I just use it, because i didn’t tried another mode, and it’s works like a charm.

Oh lol) again some problems. I just dowloaded Eclipse installer Eclipse Downloads | The Eclipse Foundation and run it and get -

I clicked more info and downloaded suggested - Download Java for OS X 2015-001 and installed it.
After that I try to run Eclipse Installer again but I get:

So Eclipse suggest me to install outdated java. Ah even here again these stupid problems with simple things.

I’m trying to download Eclipse from here - Eclipse Packages | The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects...

Which should I use? “Eclipse IDE for C/C++ Developers” or “Eclipse for Android Developers” ?
I’m trying to download both currently but ETA is 4hours oh man… speed so slow. My internet is 100MB\s

http://www.cocos2d-x.org/wiki/Android_with_Eclipse_Installation_and_Setup
http://www.cocos2d-x.org/wiki/How_to_Build_an_Android_Project_with_Eclipse

And how they solve my problem? update: Updated about 2 years ago /
Eclipse ADT Bundle http://developer.android.com/sdk/index.html - goes to Android Studio download.

Upd. I also downloaded adt-bundle-mac-x86_64-20140321.zip from link in this tutorial http://cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android and when I tried to run it I get: “Eclipse quit unexpectedly.”

@slackmoehrle are you seeing this?


The wiki is out of date. We have t removed it because we want to merge still relevant content into other docs at some point.

I can ask someone from engineering to take a look at the issues you are experiencing.