Cocos2dx v2.2.6 migration to Android studio Problem

Hi,

I’ve been following yinjimmy’s solution to get Cocos2dx version 2.2.6 working in Android Studio.

https://discuss.cocos2d-x.org/t/cocos2dx-v2-2-6-migration-to-android-studio/45495/2

It works fine when I open and compile the project he made. I can get the project to run in the simulator and on a device using this.

But when I add more class files that use #include <math.h> I get this error “error: ‘atoi’ was not declared in this scope” in the output window.

It seems like the header files from the NDK include folder are not linked, and maybe the .so and .a files from the lib folder. Does anyone know how this can be?

I have updated the references in Android.mk to the cpp files in the project/Classes folder for the shared library. So I believe they should link to <math.h> functions. Do you have any ideas why this is not the case?

By the way I am using Android Studio 3.2.1 and NDK: r10e not NDK: r10d. I couldn’t find d but would that make a difference?

Thanks for reading.

Unfortunately I can’t easily upgrade the version of my game because it is quite big.

I would be grateful if you could ask yinjimmy if he knows why <math.h> functions aren’t working in the ccp files in the Classes folder.

Thanks for your help.

It’s ok to tag me or create issue with https://github.com/c0i/cocos2d-x-v2.

I add test case.

tested ndk r10e.

1 Like