Android/iOS project synchronisation

Hi everyone,

I’m currently porting an Obj-c/cocos2d to c++/cocos2dx so it can be cross platform.
I start by using the very helpful tutorial of clawoo teh -> http://gameit.ro/2011/08/creating-an-iphone-and-android-cocos2d-x-hybrid-project/.

My problem, is that when I change HelloWorldScreen.cpp from Xcode, it doesn’t apply on the Android build.
I even tried to clean the project in Ecllpse, use the “make clean” scrip and rebuilt everything using ./build_native.sh and then Eclipse to run on the device.
The project still appears with the default “HelloWorld” text and background sprite no matter the changes I made. (for testing, I tried just to hide the sprite)

What am I missing in the synchronisation between the iOS and the Android project ?
I’m guessing I may need to modify the layout.xml of the Android, can’t everything be done programmatically ? I hate interfaces builders of any kind.

Thanks for any help

I’m just thinking of something that could explain that behaviour,

When I first put the project into Eclipse, the project was full of errors because of `Override in Cocos2dxActivity & Cocos2dxGLSurfaceView.
I commented them out and it worked fine, but it could be why it’s not working properly as it is not calling the right functions anymore?

In which case, how to I leave the `Override but remove the error ?

I should have mentioned that I have developed on Obj-C/C++ for a long time but I’m brand new with Android/Java.

Hope that can bring some clarification

It seems that, HelloWorldScreen.cpp and other cpp not compiled. Did you add them to android/helloworld/Android.mk?

I have that in my jni/helloworld/Android.mk:

LOCAL_SRC_FILES := main.cpp \
../../../Classes/AppDelegate.cpp \
../../../Classes/HelloWorldScene.cpp

The Classes folder is 3 folder abose, so the path seems accurate.

Last time I ran ./build_native.sh it printed:

Compile++ thumb  : game <= AppDelegate.cpp
Compile++ thumb  : game <= HelloWorldScene.cpp
SharedLibrary  : libgame.so
Install        : libgame.so => libs/armeabi/libgame.so

So I’m guessing it compiles them properly.

Does the new .so packed into apk?

How can I check if this is in the apk ?
I looked into the android/bin folder and couldn’t find any reference of AppDelegate and HelloWorldScene in the “org” folder.
I don’t know if that helps.

On another note, I get rid of the the @Override error in the code in case.
This is more a Java issue than cocos2dx, but I will write the answer on the forum in case someone look for it here:
In Eclipse (on MacOS at least):

  • Eclipse~~>Preferences~~>Java~~>Compiler “configure project specific settings”,
    ~~ Change from java 1.5 to 1.6
  • then “yes”
  • rebuild project

I uncompressed the .apk file after converting it in a .zip.
In the lib folder, I only have the followings:
gdbserver
libcocos2d.so
libcocosdenshion.so
libgame.so

So you were write Minggo, it appears AppDelegate & HelloWorldScene are not in the apk file.
The question is, how do I include them now?

If you clean the project in Eclipse, the .so would be packed into it. If it is packed into it, than it is too odd.
May be you should print log in HelloWorldScreen.cpp.

No, AppDelegate & HelloWorldScene are compiled to .o, and then linked to libgame.so.

Mmh, if the files are included properly and it’s not because of the @Override problem,

Do you have any suggestions on the source of the problem ?
I tried again rebuilding everything from scratch, didn’t make a difference.

I may try another project from scratch, maybe I missed a step or something… but I’m pretty sure if I have missed a step I would get an error somewhere.

Hello Fabien

Each and every time you want to deploy an APK to an Android device (or virtual device) make sure you clean the project from inside Eclipse (Go to Project > Clean) and then right click the project and Run As > Android Application

Cleaning the project will force Eclipse to refresh the bundle files and take into account the newly compiled code when creating the game APK. This is not the “make clean” command in the terminal, it is the clean from Eclipse.

Alright guys… my mistake on this one.

Basically, in the tutorial we copy the android folder to the place where the ios one is in the xcode project.
Well… I was simply compiling in the wrong folder, so obviously the files didn’t change and it didn’t work on the Android.
It was working all along…

If someone as dumb as me as this “problem” and read this,
Don’t forget to change your location in your terminal/console before recompiling _

Anyway guys, thanks for the quick replies and help.