I am trying to build my project for android on macOS using cocos compile -p android --android-studio --ap android-24
, but I keep getting the error undefined reference to 'xxtea_encrypt(unsigned char*, unsigned int, unsigned char*, unsigned int, unsigned int*)'
. I bypassed it by copying the xxtea directory in my project’s Classes
directory, but I would still like to know how to fix it.
I tried, without success:
- Add
Android.mk
file inside my project’scocos2d/external/xxtea
directory to buildxxtea
as a library - Add my project’s
cocos2d/external/xxtea
directory to theAndroid.mk
file inproj.android-studio/app/jni/Android.mk
- Build using NDK
r10c
instead ofr12b
(Note: I am not well-versed in Android, so I might be missing something trivial…)
Edit 1
I forgot to mention that I also tried what is suggested here, but it did not solve the problem. Also, I could not find the clean
option.
Edit 2: Solution
How did I miss this? The solution was to open project/cocos2d/cocos/Android.mk
and add ../external/xxtea.cpp
to LOCAL_SRC_FILES
and $(LOCAL_PATH)/../external/xxtea
to LOCAL_EXPORT_C_INCLUDES
and LOCAL_C_INCLUDES
.