Need help adding RakNet to Android Project

Need help adding RakNet to Android Project
0.0 0

#1

I have spent over 40 hours of my free time trying to figure out how to get RakNet compiling and running on android. My lack of knowledge of Android.mk and Gradle, as well as how the android NDK works, makes this a really hard task to accomplish.

I have tried: RakNet + Android + Cocos2d-x, using the actual source folder of RakNet.
It didn’t work, as there are dependencies that RakNet uses that Android Studio can’t find, and then I receive errors.

In short, if someone has gotten RakNet working with their Android Studio and is willing to make a quick step-by-step newbie guide to getting to working it will save me probably 100+ hours, because at this point I’m considering learning android.mk files and gradle files from the ground up so that I can know how to tackle this problem.

Thanks


#2

i want to know about this too


#3

Hi i have done this, the android.mk file is easier than it looks.

you must list the source files and include directories for your app and RakNet. so you don’t have to list every cpp file you can grab all .cpp file in a directory and add them to a list.
Bellow is my android.mk for example.

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/cocos/audio/include)

LOCAL_MODULE := MyGame_shared

LOCAL_MODULE_FILENAME := libMyGame

FILE_LIST := $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../RakNet/*.cpp)

LOCAL_SRC_FILES := main.cpp 
LOCAL_SRC_FILES += $(FILE_LIST:$(LOCAL_PATH)/%=%)

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

# _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