Game > Gamebase > Android Developer's Guide > Getting Started

Environments

To execute Gamebase in Android, the following system environment is required.

[Minimum Specifications]

  • User execution environment: Android API 19 (KitKat, OS 4.4) or higher
  • Build environment: Android Gradle Plugin 3.2.0 or higher
  • Development environment: Android Studio

Dependencies

Gamebase SDK Gamebase Adapter External SDK Purpose minSdkVersion
Gamebase gamebase-sdk-base
gamebase-sdk
nhncloud-core-1.8.0
nhncloud-common
nhncloud-crash-reporter-ndk
nhncloud-logger
gson-2.8.9
okhttp-3.12.13
kotlin-stdlib-1.8.0
kotlin-stdlib-common
kotlin-stdlib-jdk7
kotlin-stdlib-jdk8
kotlin-android-extensions-runtime
kotlinx-coroutines-core-1.6.4
kotlinx-coroutines-android
kotlinx-coroutines-core-jvm
Include the interface and core logic of Gamebase API 19(KitKat, OS 4.4)
Gamebase Auth Adapters gamebase-adapter-auth-appleid - Support Sign In With Apple login -
gamebase-adapter-auth-facebook facebook-login-16.1.2 Support Facebook login -
gamebase-adapter-auth-google play-services-auth-20.3.0 Support Google login -
gamebase-adapter-auth-hangame hangame-id-1.7.1 Support Hangame login -
gamebase-adapter-auth-line linesdk-5.8.1 Support LINE login -
gamebase-adapter-auth-naver naveridlogin-android-sdk-5.8.0 Support NAVER login API 21(Lollipop, OS 5.0)
gamebase-adapter-auth-payco payco-login-1.5.12 Support PAYCO login -
gamebase-adapter-auth-twitter signpost-core-1.2.1.2 Support Twitter login API 21 (Lollipop, OS 5.0)
gamebase-adapter-auth-weibo sinaweibosdk.core-13.5.0 Support Weibo login -
gamebase-adapter-auth-weibo-v4 openDefault-4.4.4 Support Weibo login -
gamebase-adapter-auth-kakaogame kakaogame.idp_kakao-3.17.5
kakaogame.gamesdk
kakaogame.common
kakao.sdk.v2-auth-2.13.0
kakao.sdk.v2-partner-auth
kakao.sdk.v2-common
play-services-ads-identifier-17.0.0
Support Kakao login API 21(Lollipop, OS 5.0)
Gamebase IAP Adapters gamebase-adapter-toastiap nhncloud-iap-core Support in-app purchase -
gamebase-adapter-purchase-amazon nhncloud-iap-amazon Support Amazon Appstore -
gamebase-adapter-purchase-galaxy nhncloud-iap-galaxy Support Samsung Galaxy Store API 21(Lollipop, OS 5.0)
Although minSdkVersion of Galaxy IAP SDK is 18, the minSdkVersion of Checkout service app that must be installed for actual purchase is 21.
gamebase-adapter-purchase-google billingclient.billing-5.0.0
nhncloud-iap-google
Support Google Play -
gamebase-adapter-purchase-huawei nhncloud-iap-huawei Support Huawei AppGallery -
gamebase-adapter-purchase-onestore nhncloud-iap-onestore Support ONE store v17 -
gamebase-adapter-purchase-onestore-v19 nhncloud-iap-onestore-v19 Support ONE store v19 -
gamebase-adapter-purchase-onestore-v21 nhncloud-iap-onestore-v21 Support ONE store v21 API 23(Marshmallow, OS 6.0)
gamebase-adapter-purchase-onestore-external nhncloud-iap-onestore-external Support ONE store external payment function -
gamebase-adapter-purchase-mycard nhncloud-iap-mycard Support MyCard payment function -
Gamebase Push Adapters gamebase-adapter-toastpush nhncloud-push-analytics
nhncloud-push-core
nhncloud-push-notification
Support Push -
gamebase-adapter-push-adm nhncloud-push-adm Support Amazon Device Messaging -
gamebase-adapter-push-fcm firebase-messaging-17.6.0
nhncloud-push-fcm
Support Firebase Cloud Messaging -

Setting

Console

[Caution]

  • Make sure that Gamebase service is enabled by creating a new project from NHN Cloud Console.
  • Make sure that Client ID is issued by each IdP console and the IDs are entered in the Gamebase console.

Register as Tester

Gamebase Test Device

Store's Tester

Gradle

Using AndroidX

  • Add the terms of use for AndroidX to build settings.

    • Android Studio

      # gradle.properties
      # >>> [AndroidX]
      android.useAndroidX=true
      android.enableJetifier=true
      
    • Unity 2019.2 or earlier

      // mainTemplate.gradle
      ([rootProject] + (rootProject.subprojects as List)).each {
          ext {
              // >>> [AndroidX]
              it.setProperty("android.useAndroidX", true)
              it.setProperty("android.enableJetifier", true)
          }
      }
      
    • Unity 2019.3 or later

      # gradleTemplate.properties
      # >>> [AndroidX]
      android.useAndroidX=true
      android.enableJetifier=true
      
    • Unreal

      <gradleProperties>
        <insert>
          android.useAndroidX=true
          android.enableJetifier=true
        </insert>
      </gradleProperties>
      

Under AGP 3.4.0

  • If the Android Gradle Plugin version is lower than 3.4.0, the build will fail, so the following declaration is required:

    # gradle.properties
    # >>> Fix for AGP under 3.4.0
    android.enableD8.desugaring=true
    android.enableIncrementalDesugaring=false
    
  • For Unity, the following declaration is required if the Editor version is 2018.4.3 or lower or 2019.1.6 or lower. (AGP version is 3.2.0)

    // mainTemplate.gradle
    ([rootProject] + (rootProject.subprojects as List)).each {
        ext {
            // >>> Fix for AGP under 3.4.0
            it.setProperty("android.enableD8.desugaring", true)
            it.setProperty("android.enableIncrementalDesugaring", false)
        }
    }
    

Root level build.gradle

  • To use Huawei IAP, add the following declaration to build.gradle or settings.gradle (AGP 7.1 or later) at the project level (root level).
buildscript {
    repositories {
        ...
        // [Huawei App Gallery] Maven repository address for the HMS Core SDK.
        maven { url 'https://developer.huawei.com/repo/' }
    }

    dependencies {
        ...
        // [Huawei App Gallery] AppGallery Connect plugin configuration. please use the latest plugin version.
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'
    }
}

Define Adapters

  • Declare Gamebase version and authentication to use, and the payment and the push modules in the build.gradle file.
// >>> [Huawei App Gallery] agconnect plugin for huawei - when Native Android build
apply plugin: 'com.huawei.agconnect'

repositories {
    // >>> For Gamebase SDK
    mavenCentral()
    ...

    // >>> [Huawei App Gallery]
    maven { url 'https://developer.huawei.com/repo/' }

    // >>> [ONE store v21]
    maven { url 'https://repo.onestore.co.kr/repository/onestore-sdk-public' }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // >>> Gamebase Version
    def GAMEBASE_SDK_VERSION = 'x.x.x'

    // >>> Gamebase - Add Auth Adapter
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-google:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-facebook:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-appleid:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-twitter:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-naver:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-line:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-payco:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-weibo:$GAMEBASE_SDK_VERSION"

    // >>> Gamebase - Select Purchase Adapter
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-google:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore-v21:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore-external:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-galaxy:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-amazon:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-huawei:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-mycard:$GAMEBASE_SDK_VERSION"

    // >>> Gamebase - Select Push Adapter
    implementation "com.toast.android.gamebase:gamebase-adapter-push-fcm:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-push-adm:$GAMEBASE_SDK_VERSION"

    // >>> Regarding how to use the following modules, please contact the Customer Center.
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-hangame:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-hangamejp:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-hangamejpemail:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-kakaogame:$GAMEBASE_SDK_VERSION"
    // >>> [Weibo v4]
    // https://github.com/nhn/toast.gamebase.android.sample/tree/main/weibo_sdk
    implementation files('libs/openDefault-4.4.4.aar')
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-weibo-v4:$GAMEBASE_SDK_VERSION"
    // >>> [ONE store v16]
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore-v16:$GAMEBASE_SDK_VERSION"
    // >>> [ONE store v17]
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore:$GAMEBASE_SDK_VERSION"
    // >>> [ONE store v19]
    // https://github.com/ONE-store/onestore_iap_release/tree/iap19-release/android_app_sample/app/libs
    implementation files('libs/iap_sdk-v19.00.02.aar')
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore-v19:$GAMEBASE_SDK_VERSION"
    // >>> [Push Custom Receiver]
    implementation "com.toast.android.gamebase:gamebase-adapter-push-notification:$GAMEBASE_SDK_VERSION"
}

android {
    compileOptions {
        // >>> [AndroidX]
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // >>> [Weibo IdP]
        ndk {
            abiFilters 'armeabi' // , 'armeabi-v7a', 'arm64-v8a'
        }
    }
}

Resources

Weibo IdP

  • Depending on your build target, download the so files from the following URLs and copy them to your project.
    • https://github.com/sinaweibosdk/weibo_android_sdk/tree/master/so
  • In case of Android Studio build
    • Copy under the project's src/main/java/jniLibs folder.
    • Add so file to Android Studio project
  • In case of Unity build
    • Copy the so and foler under the Assets/Plugins/Android/libs.
    • Add so file to Unity project

Huawei Store

  • You must add the AppGallery Connection configuration file (agconnect-services.json) to the assets folder.
    • Log in to AppGallery Connect and click on My Projects.
    • Select an app from your project.
    • Go to Project settings > General information.
    • Download the agconnect-services.json file from App information.
    • For Android Studio builds
      • Copy the agconnect-services.json file to the assets folder in your project.
    • For Unity builds
      • Copy the agconnect-services.json file to the Assets/StreamingAssets folder in your project.

Firebase Notification

  • For Android Studio build
  • For a Unity build

    • Download the google-services.json file from 'Firebase Console > Project Settings' along with the generate_xml_from_google_services_json.exe file for xml conversion, and execute the command below to convert the json file to an xml file.

      "{UnityProject}\Firebase\Editor\generate_xml_from_google_services_json.exe" -i "{JsonFilePath}\google-services.json" -o "{UnityProject}\Assets\Plugins\Android\res\values\google-services.xml" -p "{PackageName}"
      
    • Add the converted xml file to the 'Android Library Project' as a resource.

  • For a Unreal build

    • The Gamebase Unreal SDK includes an empty google-service-json.xml file, so follow the instructions in 'For a Unity build' to change to an xml file from the json file.
    • If there is Content automatically creating xml in a similar form like EasyFirebase, there may be a build error due to resource duplication. At this time, remove the google-service-json.xml file.

AndroidManifest.xml

Contact

  • To make an inquiry in Game > Gamebase > Android SDK User Guide > ETC > Additional Features > Contact with photos and media, you need permission to read storage.

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
  • If your app is targeting Android 13 (API Level 33) or later, in addition to the storage read permission, you also need to decare the following detailed media permissions.

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    
  • If permissions are declared, the Gamebase SDK will automatically request runtime permissions at file upload time.

Facebook IdP

  • Declares the App ID and the client token to initialize Facebook SDK.
    • Instead of declaring the values directly, set them to reference resources, as shown in the example below.
    • The App ID is not required, but the client token is required starting with Facebook SDK v13.0 for successful login.
    • The client token can be found in Facebook for Developers > Settings > Advanced Settings > Security.

AndroidManifest.xml

<manifest ...>
    <application ...>
        ...
        <!-- [Facebook] Configurations begin -->
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
        <!-- [Facebook] Configurations end -->
        ...
    </application>
</manifest>

res/values/strings.xml

<resources>
    <!-- [Facebook] Facebook APP ID & Client Token -->
    <string name="facebook_app_id">123456789012345</string>
    <string name="facebook_client_token">a01234bc56de7fg89012hi3j45k67890</string>
</resources>

Weibo IdP

  • In order for Weibo IdP to work properly, android:networkSecurityConfig attribute must be added to application tag, and the name of the xml file which has declared the weibo/sina-related URL must be set.
<application android:networkSecurityConfig="@xml/my_network_security_config"
    ...>
    ...
</application>
  • res/xml/my_network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <!-- Weibo SDK start -->
        <domain includeSubdomains="true">sina.cn</domain>
        <domain includeSubdomains="true">weibo.cn</domain>
        <domain includeSubdomains="true">weibo.com</domain>
        <domain includeSubdomains="true">sinaimg.cn</domain>
        <domain includeSubdomains="true">sinajs.cn</domain>
        <domain includeSubdomains="true">sina.com.cn</domain>
        <!-- Weibo SDK end -->
    </domain-config>
</network-security-config>

ONE Store

  • ONE store supports both full payment screen and payment popup window.
    • You can add AndroidManifest.xml to meta-data to select the full payment screen ("full") or payment popup window ("popup") screen.
    • If meta-data is not set, the default ("full") is applied.
<manifest>
    ...
    <application>
        ...
        <!-- [ONE store] Configurations begin -->
        <!-- popup:payment popup window / full:full payment screen -->
        <meta-data
            android:name="iap:view_option"
            android:value="popup | full" />
        <!-- [ONE store] Configurations end -->
        ...
    </application>
</manifest>
Payment screen Set value
Full payment screen "full"
Payment popup window "popup"

Huawei Store

  • When building multi platforms like Unity, add the following instead of the apply plugin to enable normal payment.
  • Enter the values of the cp_id and app_id fields in agconnect-services.json into the meta-data of the AndroidManifest.xml.
<meta-data  
    android:name="com.huawei.hms.client.appid"  
    android:value="appid=123456789">  
</meta-data>
<meta-data
    android:name="com.huawei.hms.client.cpid"
    android:value="cpid=1234567891234">
</meta-data>

Caution: Huawei App Gallery must be installed on your device to make payment normally.

MyCard

  • To integrate with MyCard payment, you must use GamebaseMyCardApplication. Add the following to the AndroidManifest.xml.
<application
    android:name="com.toast.android.gamebase.purchase.mycard.GamebaseMyCardApplication"
  ...>
  ...
</application>

  • If you define and use your application class by extending Applcation class, inherit from GamebaseMyCardApplication.
class MyApplication: GamebaseMyCardApplication() {
    ...
}
  • To run the payment test, add 'test_mode' to the AndroidManifest.xml. Otherwise, the default value is false.
<application>
  <meta-data android:name="iap:test_mode" android:value="true | false"/>
</application>

Notification Options

  • You can use the following method to set the notification option:

Example

<!-- When you have multiple applications sharing an Gamebase project, use this field to identify each application. -->
<meta-data android:name="com.nhncloud.sdk.push.deviceId.salt"
           android:value="ApplicationForGoogleStore" />

<!-- Notification priority -->
<meta-data android:name="com.toast.sdk.push.notification.default_priority"
           android:value="1"/>
<!-- Notification background color -->
<meta-data android:name="com.toast.sdk.push.notification.default_background_color"
           android:resource="@color/defaultNotificationColor"/>
<!-- LED light -->
<meta-data android:name="com.toast.sdk.push.notification.default_light_color"
           android:value="#0000ff"/>
<meta-data android:name="com.toast.sdk.push.notification.default_light_on_ms"
           android:value="0"/>
<meta-data android:name="com.toast.sdk.push.notification.default_light_off_ms"
           android:value="500"/>
<!-- Small icon -->
<meta-data android:name="com.toast.sdk.push.notification.default_small_icon"
           android:resource="@drawable/ic_notification"/>
<!-- Sound -->
<meta-data android:name="com.toast.sdk.push.notification.default_sound"
           android:value="notification_sound"/>
<!-- Vibrate pattern -->
<meta-data android:name="com.toast.sdk.push.notification.default_vibrate_pattern"
           android:resource="@array/default_vibrate_pattern"/>
<!-- Use badge icon or not -->
<meta-data android:name="com.toast.sdk.push.notification.badge_enabled"
           android:value="true"/>
<!-- Enable notification when application is foreground. -->
<meta-data android:name="com.toast.sdk.push.notification.foreground_enabled"
           android:value="false"/>
meta-data key value type description
com.nhncloud.sdk.push.deviceId.salt String If different applications share a single Gamebase project, push does not work properly.
You must specify a different random 'salt' value for each app.
com.toast.sdk.push.notification.default_priority int Priorities.
You can set the following five values:
NoticationComapt.PRIORITY_MIN : -2
NoticationComapt.PRIORITY_LOW : -1
NoticationComapt.PRIORITY_DEFAULT : 0
NoticationComapt.PRIORITY_HIGH : 1
NoticationComapt.PRIORITY_MAX : 2
com.toast.sdk.push.notification.default_background_color int Background color.
com.toast.sdk.push.notification.default_light_color int LED color.
com.toast.sdk.push.notification.default_light_on_ms int Time when the LED light turns on.
com.toast.sdk.push.notification.default_light_off_ms int Time when the LED light turns off.
com.toast.sdk.push.notification.default_small_icon resource id Resource identifier in small icon.
com.toast.sdk.push.notification.default_sound String Notification sound file name.
Works only in AOS 8.0 or earlier.
The notification sound will change as you specify the .mp3 or .wav file name in the 'res/raw' folder.
com.toast.sdk.push.notification.default_vibrate_pattern long[] Vibration pattern.
com.toast.sdk.push.notification.badge_enabled boolean Whether to use a badge icon or not.
com.toast.sdk.push.notification.foreground_enabled boolean Whether to use the foreground notification or not.

Android 11

[Caution]

If you are using
the Android Gradle
plugin version...
...upgrade to: Unity Editor
4.1.* N/A (no upgrade needed) -
4.0.* 4.0.1 -
3.6.* 3.6.4 2020.1 ~
3.5.* 3.5.4 -
3.4.* 3.4.3 2018.4.4 ~
2019.1.7 ~
3.3.* 3.3.3 -
3.2.* Not supported 2017.4.17 ~
2018.3 ~ 2018.4.3
2019.1.0 ~ 2019.1.6
3.0.* Not supported 2018.2
2.3.* Not supported 2017.3 ~ 2017.4.16
2018.1
2.1.* Not supported Unity 5
2017.1 ~ 2017.2
<manifest>
    <!-- [Android11] settings start -->
    <queries>
        <!-- [All SDK] AppToWeb Authenthcation support start -->
        <package android:name="com.android.chrome" />
        <package android:name="com.chrome.beta" />
        <package android:name="com.chrome.dev" />
        <package android:name="com.sec.android.app.sbrowser" />
        <!-- [All SDK] AppToWeb Authenthcation support end -->

        <!-- [Facebook] Configurations begin -->
        <package android:name="com.facebook.katana" />
        <!-- [Facebook] Configurations end -->

        <!-- [PAYCO/Hangame] Configurations begin -->
        <package android:name="com.nhnent.payapp" />
        <!-- [PAYCO/Hangame] Configurations end -->

        <!-- [Hangame] Configurations begin -->
        <package android:name="com.nhn.hangameotp" />
        <package android:name="com.sci.siren24.ipin" />
        <package android:name="kr.co.samsungcard.mpocket" />
        <package android:name="com.lcacApp" />
        <package android:name="com.shcard.smartpay" />
        <package android:name="com.hyundaicard.appcard" />
        <package android:name="com.kbcard.cxh.appcard" />
        <package android:name="com.hanaskcard.paycla" />
        <package android:name="kvp.jjy.MispAndroid320" />
        <package android:name="nh.smart.nhallonepay" />
        <!-- [Hangame] Configurations end -->

        <!-- [NAVER] Configurations begin -->
        <package android:name="com.nhn.android.search" />
        <!-- [NAVER] Configurations end -->

        <!-- [Weibo] Configurations begin -->
        <package android:name="com.weico.international" />
        <package android:name="com.sina.weibo" />
        <!-- [Weibo] Configurations end -->

        <!-- [ONE store] Configurations begin -->
        <intent>
            <action android:name="com.onestore.ipc.iap.IapService.ACTION" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="onestore" />
        </intent>
        <!-- [ONE store] Configurations end -->

        <!-- [Galaxy store] Configurations begin -->
        <package android:name="com.sec.android.app.samsungapps" />
        <!-- [Galaxy store] Configurations end -->
    </queries>

    <!-- [Amazon Appstore] Configuration begin -->
    <uses-permission
        android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />
    <!-- [Amazon Appstore] Configuration end -->

    <!-- [Android11] settings end -->
</manifest>
  • For Amazon Appstore, add the QUERY_ALL_PACKAGES permission instead of the 'queries' element.

[Caution]

  • The QUERY_ALL_PACKAGES permission is declared exclusively for Amazon Appstore, so be careful not to apply it when running Google Play builds.

Proguard

overview flow

3rd-Party Provider SDK Guide

API Reference

  • API Reference is included in SDK.

API Deprecate Governance

The API which is not supported by Gamebase anymore is processed as deprecated (deprecate). A deprecated API can be deleted without any prior notice when the following conditions are met:

  • Minor version updates of five or more times.
    • Gamebase version format - XX.YY.ZZ
      • XX: Major
      • YY: Minor
      • ZZ: Hotfix
  • Time elapse of at least five months
TOP