AnySDK Framework
Cocos Creator built-in Cocos engine includes AnySDK Framework libraries. The platform project that built by developer already includes AnySDK Framework. The chapter introduces how to use AnySDK selectivity.
Use AnySDK
Native
- According to AnySDK Official Documentation integrates AnySDK`s relevant interface directly
H5
Check the AnySDK option when you built web-mobile project
According to AnySDK H5 Integrated Documentation integrates AnySDK H5`s relevant interface directly
No need to use AnySDK
If developers do not need to use AnySDK, currently only support to delete the relevant files manually. Steps:
Delete
frameworks/runtime-src/Classesdirectory`sjsb_anysdk_basic_conversions.cpp manualanysdkbindings.cpp jsb_anysdk_protocols_auto.cpp SDKManager.cpp jsb_anysdk_basic_conversions.h manualanysdkbindings.hpp jsb_anysdk_protocols_auto.hpp SDKManager.hDelete
main.jsfile`s// anysdk scripts if (cc.sys.isNative && cc.sys.isMobile) { jsList = jsList.concat(['jsb_anysdk.js', 'jsb_anysdk_constants.js']); }need to add a folder
build-templatesin the project path, the sub-folder inbuild-templatesshould named with platform. Copymain.jsthat deleted code to sub-folder Folder Structure:project-folder |--assets |--build |--build-templates |--web-mobile |--main.js |--jsb-binary |--main.js |--jsb-default |--main.jsEclipse project
- Delete libs directory
slibPluginProtocol.jar` file - Delete res directory`s
drawable/plugin_btn_close.png drawable/plugin_ui_ad.png values-en/plugin_string.xml values/plugin_string.xml layout/plugin_ads.xml layout/plugin_login.xml - Delete jni directory
s Android.mk filesLOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic Delete jni directory
s Android.mk filesLOCAL_SRC_FILES := ../../Classes/SDKManager.cpp \ ../../Classes/jsb_anysdk_basic_conversions.cpp \ ../../Classes/manualanysdkbindings.cpp \ ../../Classes/jsb_anysdk_protocols_auto.cppDelete jni directory
s Application.mk files macro definitionAPP_CPPFLAGS := -DPACKAGE_AS- Modify
src/org/cocos2dx/javascript/SDKWrapper.javafilesprivate final static boolean PACKAGE_AS = true;,truechanges tofalse`
- Delete libs directory
- Android Studio project
- Delete libs directory
slibPluginProtocol.jar` file - Delete res directory`s
mipmap/plugin_btn_close.png mipmap/plugin_ui_ad.png values-en/plugin_string.xml values/plugin_string.xml layout/plugin_ads.xml layout/plugin_login.xml - Delete jni directory
Android.mk filesLOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - Delete jni directory
Android.mk filesLOCAL_SRC_FILES := ../../Classes/SDKManager.cpp \ ../../Classes/jsb_anysdk_basic_conversions.cpp \ ../../Classes/manualanysdkbindings.cpp \ ../../Classes/jsb_anysdk_protocols_auto.cpp - Delete jni file
s Application.mk files macro definitionAPP_CPPFLAGS := -DPACKAGE_AS - Modify
src/org/cocos2dx/javascript/SDKWrapper.javafilesprivate final static boolean PACKAGE_AS = true;,truechanges tofalse`
- Delete libs directory
- Xcode project
- Delete
libPluginProtocol.alibrary - Xcode delete
libPluginProtocol.areference - Xcode delete
Classesfile referencejsb_anysdk_basic_conversions.cpp manualanysdkbindings.cpp jsb_anysdk_protocols_auto.cpp SDKManager.cpp jsb_anysdk_basic_conversions.h manualanysdkbindings.hpp jsb_anysdk_protocols_auto.hpp - Delete preprocessor
PACKAGE_AS
- Delete
- Web project
- Manual: delete index.html file`s
<script charset="utf-8" id="protocols" type="text/javascript"> var protocols = document.createElement("script"); protocols.onload = function () { anysdk.agentManager.init(); anysdk.agentManager.loadAllPlugins(function (code, msg) { }); }; protocols.src = "http://statics.h5.anysdk.com/protocols/protocols.js"; document.body.appendChild(protocols); </script> - Auto: no check
AnySDKoption when built-in
- Manual: delete index.html file`s
After the delete AnySDK still need to use
- Use Cocos Console command to call
cocos package import -b anysdk -p project-path --anysdk
Update AnySDK Framework
- Use Cocos Console command to call
cocos package update -p project-path --anysdk, updates can be realized
FAQ
- Crash in channel package
- Reason:
frameworks/runtime-src/Classes/SDKManager.cppfilesloadAllPluginsfunction has been invokedinit` function in built-in Cocos project,it has been unable to be taken effect that developers invoked in JS code - Solution: No need to invoke initialize interface,but the developer need to modify the
loadAllPluginsfunction offrameworks/runtime-src/Classes/SDKManager.cppfile and add appKey、appSecret、privateKey、oauthLoginServer parameters.
- Reason: