Project Configuration

Last updated: 2020-12-16 15:12:12

    This document describes how to configure a Cocos2d project for the GME APIs for Cocos2d.

    Cocos Creator Access

    If you use Cocos Creator access, see Getting Started with Tencent Cloud GME.

    SDK Preparations

    1. Download the applicable demo and SDK. For more information, please see SDK Download Guide.
    2. Decompress the obtained SDK resources.
    3. The folder contains:
      • GMESDK: GME SDK framework file.
      • GMECocosDemo: GME SDK demo project.


    The SDK supports compilation on macOS.

    iOS Xcode Configuration

    1. Add the framework to the Xcode project and set the header file import location (the framework file in the GMESDK folder must be added to the project).
    2. Add dependent libraries as shown below:

    Android Configuration

    1. Add gmesdk.jar to the libs library.
    2. Import the so file into Activity as shown below:
      public class AppActivity extends Cocos2dxActivity {
       static final String TAG = "AppActivity";
       static OpensdkGameWrapper gameWrapper ;
       static {
    3. Initialize in the oncreate function exactly in the following sequence:
      protected void onCreate(Bundle savedInstanceState) {
           //Initialize exactly in the following sequence
           gameWrapper = new OpensdkGameWrapper(this);
           runOnGLThread(new Runnable() {
               public void run() {
    4. Configure your project for compilation options by referring to the in the GME Demo for Cocos.
      • Path: GMECocos/GMECocosDemo/
      • Path to the file: /Users/username/Downloads/GMECocos/GMESDK/android/bin/

    Exporting to Different Platforms

    Project configuration is required before you can export executables from the Cocos2d engine for different platforms:

    Android platform

    Configuring Application Permissions

    Add the following permissions in the AndroidManifest.xml file of the project:

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    If the voice messaging and speech-to-text feature is to be used, add the following under the application node in the manifest file:

    <application android:usesCleartextTraffic="true" >

    iOS platform

    Grant permission:

    • Microphone Usage Description: allows microphone permission.
    • Grant the Allow Arbitrary Loads permission as shown below:

    Windows platform

    Please refer to SDK Download Guide to download Windows SDK and import it into the project.