I’m trying to compile my game for Android Studio, and I’m getting the following errors:
/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/../cocos2d/cocos/ui/UIWidget.cpp:172: error: undefined reference to 'vtable for cocos2d::ui::Widget'
/Users/matthewlehew/Developer/Android/ndk/android-ndk-r10c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/../cocos2d/cocos/ui/UIWidget.cpp:177: error: undefined reference to 'vtable for cocos2d::ui::Widget'
/Users/matthewlehew/Developer/Android/ndk/android-ndk-r10c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/../cocos2d/cocos/ui/UIWidget.cpp:265: error: undefined reference to 'typeinfo for cocos2d::ui::Widget'
/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/../cocos2d/cocos/ui/UIWidget.cpp:551: error: undefined reference to 'typeinfo for cocos2d::ui::Widget'
/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/../cocos2d/cocos/ui/UIWidget.cpp:712: error: undefined reference to 'typeinfo for cocos2d::ui::Widget'
/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/../cocos2d/cocos/ui/UIWidget.cpp:1196: error: undefined reference to 'typeinfo for cocos2d::ui::Widget'
./obj/local/armeabi/libui.a(UILayout.o):UILayout.cpp:vtable for cocos2d::ui::Layout: error: undefined reference to 'cocos2d::ui::Widget::setGlobalZOrder(float)'
./obj/local/armeabi/libui.a(UIListView.o):UIListView.cpp:vtable for cocos2d::ui::ListView: error: undefined reference to 'cocos2d::ui::Widget::setGlobalZOrder(float)'
./obj/local/armeabi/libui.a(UIPageView.o):UIPageView.cpp:vtable for cocos2d::ui::PageView: error: undefined reference to 'cocos2d::ui::Widget::setGlobalZOrder(float)'
./obj/local/armeabi/libui.a(UIScrollView.o):UIScrollView.cpp:vtable for cocos2d::ui::ScrollView: error: undefined reference to 'cocos2d::ui::Widget::setGlobalZOrder(float)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make: Leaving directory `/Users/matthewlehew/Documents/CocosProjects/RueRunner/proj.android-studio/app'
Error running command, return code: 2.
The game compiles in Xcode for iOS, I’m only getting the error when attempting to compile for Android. My Android.mk file is as follows:
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)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/extensions)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos/ui)
$(call import-add-path,$(LOCAL_PATH))
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
CPP_FILES := $(shell find $(LOCAL_PATH)/../../../Classes -name *.cpp)
CPP_FILES += $(shell find $(LOCAL_PATH)/../../../Classes/GameSparksSDK -name *.c)
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(shell find $(LOCAL_PATH)/../../../Classes -type d)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../cocos2d/extensions/PELoader
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_STATIC_LIBRARIES += cocos_ui_static
LOCAL_WHOLE_STATIC_LIBRARIES := PluginIAP
LOCAL_WHOLE_STATIC_LIBRARIES += sdkbox
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_ui_static
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
$(call import-module, ./sdkbox)
$(call import-module, ./pluginiap)
$(call import-module,ui)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END
Anyone got any tips? Have I forgotten something? Thanks!