Search code examples
android-studiococos2d-x

cocos2d-x and run in android Studio


i will run a cocos project in android Studio but when type command cocos compile -p android in cmd.exe say error in ndk. and android.mk is :

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

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

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

$(call import-module,.)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

my cmd


Solution

  • As now According to me you are using NDK 12 or greater. These NDK by default add arm64-v8a architecture support. You don't have libfreetype.a file in cocos2d/external/freetype2/prebuilt/android/arm64-v8a/ folder because cocos2d not generate by default, it slow down the compiling speed.

    Solution is you can use NDK 11 or lesser
    otherwise use latest version of cocos2d-x and enable ABI support to all arch armeabi armeabi-v7a x86 arm64-v8a instead of armeabi only

    Some of concerning topic/issue

    https://github.com/cocos2d/cocos2d-x/issues/15713
    https://github.com/cocos2d/cocos2d-x/issues/15566