@victor88888 i tried to implement the anySDK using the following link anySDk with cocos2d-JS (cn) with help of anySDK Cpp tutorial (en).
And here are the steps that I followed:
1- download the anySDK framework
2- copy anysdkConst.js to src folder
3- update jslist on project.json to include the anysdkConst.js
"JsList" : [
"Src / resource.js" ,
"Src / anysdkConst.js" ,
"Src / app.js"
]
4- create a “protocols” directory @ my COCOS_PROJECT_HOME /frameworks / runtime-src / proj.android
5- copy android and include directories from anySDK framwork: AnySDK…\framework\protocols_gnustl_static to protocols_gnustl_static to the “protocols” directory that we recently created.
6- copy and merge anySDK res directory AnySDK…\framework\protocols_gnustl_static\res content into my project res directory.
7- copy the The AnySDK_Framework_JS / 3.x files into COCOS_PROJECT_HOME/frameworks / runtime-src /Classes
8- Edit COCOS_PROJECT_HOME/frameworks /proj.android/jni/Android.mk file
- add :
../../Classes/autoanysdkbindings.cpp \
../../Classes/manualanysdkbindings.cpp \
9- always in Android.mk add to LOCAL_C_INCLUDES:
$(LOCAL_PATH)/../protocols/android \
$(LOCAL_PATH)/../protocols/include \
10- add LOCAL_WHOLE_STATIC_LIBRARIES += PluginProtocolStatic in Android.mk as well.
11- Add library path:below the last line of android.mk add: $(call import-module,protocols/android)
(i've got an error during compile for duplicates, as this was already loaded by admob, so i removed this line, don't know if this is the correct action, but after removing it the error disappeared)
12- modify COCOS_PROJECT_HOME/frameworks //runtime-src/proj.android/build-cfg.json
- modify Ndk_module_path, by adding “” at the end !!! strange, i’m not sure why …
13- copy AnySDK_Framework_JS / Framework / protocols_gnustl_static / Android libPluginProtocol.jar to COCOS_PROJECT_HOME\frameworks\runtime-src\proj.android\libs
14- edit PROJECT_HOME\frameworks\runtime-src\proj.android\jni\hellojavascript\main.cpp as following
15- edit and add the following permissions to PROJECT_HOME\frameworks\runtime-src\proj.android\AndroidManifest.xml
and remove those that was previously added, if any:
<Uses-permission Android: name = "android.permission.INTERNET" />
<Uses-permission Android: name = "android.permission.ACCESS_NETWORK_STATE" />
<Uses-permission Android: name = "android.permission.ACCESS_WIFI_STATE" />
<Uses-permission Android: name = "android.permission.RESTART_PACKAGES" />
<Uses-permission Android: name = "android.permission.KILL_BACKGROUND_PROCESSES" />
16- Modify proj.android/src/org/cocos2dx/javascript/AppActivity.java file.
(add PluginWrapper.init ( this ); to the onCreate() function, and import anySDK plugin wrapper)
import com.anysdk.framework.PluginWrapper;
public class MainActivity extends Activity {
protected void onCreate (Bundle savedState)
{
super.onCreate (savedState);
PluginWrapper.init ( this );
}
17- also add to appActivity.java
@Override
protected void onDestroy () {
PluginWrapper.onDestroy ();
super.onDestroy ();
}
@Override
protected void onPause () {
PluginWrapper.onPause ();
super.onPause ();
}
@Override
protected void onResume () {
PluginWrapper.onResume ();
super.onResume ();
}
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
PluginWrapper.onActivityResult (requestCode, resultCode, data);
super.onActivityResult (requestCode, resultCode, data);
}
@Override
protected void onNewIntent (Intent intent) {
PluginWrapper.onNewIntent (intent);
super.onNewIntent (intent);
}
@Override
protected void onStop () {
PluginWrapper.onStop ();
super.onStop ();
}
@Override
protected void onRestart () {
PluginWrapper.onRestart ();
super.onRestart ();
}
18- Modify COCOS_PROJECT_HOME /frameworks/runtime-src/Classes AppDelegate.cpp document (for v3.x)
add:
sc-> addRegisterCallback (register_all_autoanysdkbindings);
sc-> addRegisterCallback (register_all_anysdk_manual);
before #if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
19- add reference also to AppDelegate.cpp
#include "autoanysdkbindings.hpp"
#include "manualanysdkbindings.hpp"
20- load any sdk in js
// Note: This appKey, appSecret, privateKey, asked to replace the value inside their own packaging tools (login packing tools, the three parameters of the game management interface display).
var appKey = "CED525C0-8D41-F514-96D8-90092EB3899A";
var appSecret = "a29b4f22aa63b8274f7f6e2dd5893d9b";
var privateKey = "963C4B4DA71BC51C69EB11D24D0C7D49";
var oauthLoginServer = "http://oauth.anysdk.com/api/OauthLoginDemo/Login.php";
var agent = anysdk.AgentManager.getInstance ();
// Init
agent.init (appKey, appSecret, privateKey, oauthLoginServer);
// Load
agent.loadALLPlugin ();
after all those steps, i’m tryig now to compile the project, but i’m getting errors and trying to fix them. i’ll post them later if i wasn’t able to proceed.
Don’t know if this is the correct scenario, thanks if you could confirm.