Cocos2d-x so library file Android. mk
If a third-party SDK is used in the project, most of the files in the. So dynamic shared library are packaged for use. For how to use them, see the analysis below.
1. Obtain the library file
Assume that the library file we get is libxxx. So (Note: The naming method of the. So file can be Baidu ). Create a prebuilt folder in the JNI directory and put the obtained library files
Copy to this folder. 2. Use library files
To use the library file, you must modify Android. mk and add the following code to the MK file:
include $(CLEAR_VARS) LOCAL_MODULE := xxx LOCAL_SRC_FILES := prebuilt/libxxx.so include $(PREBUILT_SHARED_LIBRARY) LOCAL_SHARED_LIBRARIES := xxx
Calling in Java
static { System.loadLibrary("XXX"); System.loadLibrary("cocos2dcpp");}
3. Compile
After compilation, the libxxx. So file is generated in the libs/armeabi directory and compiled into the APK.
4. wanpu example
The following is the MK file of the wanpu platform demo. It is posted here to help you understand the following usage methods.
Local_path: = $ (call my-DIR) include $ (clear_vars) local_module: = uninstall // Step 1 local_src_files: = prebuilt/libuninstall. so // Step 2 include $ (prebuilt_shared_library) // step 3 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_sharedlocal_module_filename: = libcocos2dcpplocal_src_files: = hellocpp/main. CPP .. /.. /classes/appdelegate. CPP .. /.. /classes/helloworldscene. CPP .. /.. /classes/wapsad. cpplocal_c_includes: = $ (local_path )/.. /.. /classeslocal_whole_static_libraries: = cocos2dx_staticlocal_whole_static_libraries + = cocosdenshion_staticlocal_whole_static_libraries: = bytes + = cocostudio_static # bytes + = box2d_static # bytes + = cocosbuilder_static # bytes + = spine_static # bytes + = cocostudio_static # bytes + = cocos_network_static # bytes + = bytes $ (build_shared_library) include $ (clear_vars) local_shared_libraries: = uninstall // Step 4 $ (call import-module ,.) $ (call import-module, audio/Android) $ (call import-module, box2d) $ (call import-module, editor-support/cocostudio) $ (call import-module, extensions) # $ (call import-module, box2d) # $ (call import-module, editor-support/cocosbuilder) # $ (call import-module, editor-support/spine) # $ (call import-module, editor-support/cocostudio) # $ (call import-module, network) # $ (call import-module, extensions)
Use third-party so libraries in Cocos2d-x