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 16 (JellyBean, OS 4.1) 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
toast-core-0.31.1
toast-common
toast-crash-reporter-ndk
toast-logger
gson-2.8.7
okhttp-3.12.5
kotlin-stdlib-1.5.21
kotlin-stdlib-common
kotlin-stdlib-jdk7
kotlin-stdlib-jdk8
kotlin-android-extensions-runtime
kotlinx-coroutines-core-1.5.1
kotlinx-coroutines-android
kotlinx-coroutines-core-jvm
Include interface and core logic of Gamebase API 16 (JellyBean, OS 4.1)
Gamebase Auth Adapters gamebase-adapter-auth-appleid - Support Sign In With Apple login API 19 (Kitkat, OS 4.4)
gamebase-adapter-auth-facebook facebook-login-11.3.0 Support Facebook login -
gamebase-adapter-auth-google play-services-auth-19.0.0 Support Google login -
gamebase-adapter-auth-hangame hangame-id-1.5.2 Support Hangame login -
gamebase-adapter-auth-line linesdk-5.8.0 Support LINE login API 17 (JellyBean MR1, OS 4.2)
gamebase-adapter-auth-naver naveridlogin-android-sdk-4.4.1 Support NAVER login -
gamebase-adapter-auth-payco payco-login-1.5.7 Support PAYCO login -
gamebase-adapter-auth-twitter signpost-core-1.2.1.2 Support Twitter login API 19 (Kitkat, OS 4.4)
gamebase-adapter-auth-weibo sinaweibosdk.core-12.5.0 Support Weibo login API 19 (Kitkat, OS 4.4)
gamebase-adapter-auth-weibo-v4 openDefault-4.4.4 Support Weibo login -
gamebase-adapter-auth-kakaogame kakaogame.idp_kakao-3.11.5
kakaogame.gamesdk
kakaogame.common
kakao.sdk.v2-auth-2.5.2
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 toast-gamebase-iap-0.18.5
toast-iap-core
Support in-app purchase -
gamebase-adapter-purchase-amazon toast-iap-amazon Support Amazon Appstore -
gamebase-adapter-purchase-galaxy toast-iap-galaxy Support 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-3.0.3
toast-iap-google
Support Google Play Store -
gamebase-adapter-purchase-huawei toast-iap-huawei Support Huawei App Gallery API 19 (Kitkat, OS 4.4)
gamebase-adapter-purchase-onestore toast-iap-onestore Support ONE store v17
Currently v19 is not supported
-
gamebase-adapter-purchase-onestore-external toast-iap-onestore-external Support ONE store external payment function -
Gamebase Push Adapters gamebase-adapter-toastpush toast-push-analytics
toast-push-core
toast-push-notification
Support push notifications -
gamebase-adapter-push-adm toast-push-adm Support Amazon Device Messaging -
gamebase-adapter-push-fcm firebase-messaging-17.6.0
toast-push-fcm
Support Firebase Notification -

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)
        }
    }
    

Define Adapters

  • Declare Gamebase version and authentication to use, and the payment and the push modules in the build.gradle file.
repositories {
    // >>> For Gamebase SDK
    mavenCentral()
    ...

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

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"
    // >>> For ONE Store, only v17 can be used and v19 is currently not supported.
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore:$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"

    // >>> 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"
    implementation "com.toast.android.gamebase:gamebase-adapter-auth-weibo-v4:$GAMEBASE_SDK_VERSION"
    implementation "com.toast.android.gamebase:gamebase-adapter-purchase-onestore-v16:$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

Huawei Store

  • You must add the AppGallery Connection configuration file (agconnect-service.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-service.json file from App information.
    • For Android Studio builds
      • Copy the agconnect-service.json file to the assets folder in your project.
    • For Unity builds
      • Copy the agconnect-service.json file to the Assets/StreamingAssets folder in your project.

Firebase Notification

  • For Android Studio build
  • For a Unity build

    • If the Firebase Unity SDK Package has been installed, you can use the following command to execute generate_xml_from_google_services_json.exe file to convert json files into xml files.

      "{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}"
      
    • If the Firebase Unity SDK Package is not installed, go to 'Firebase Console > Project Settings' to download google-services.json file, and then follow the guide below to directly create a string resource (xml) file. The created file must be included in 'Assets/Plugins/Android/res/values/' folder. Depending on the Firebase service link, the contents of the google-services.json file may vary. Download google-services.json

<!-- Assets/Plugins/Android/res/values/google-services-json.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="firebase_database_url" translatable="false">https://gamebase-sample-00000000.firebaseio.com</string>
    <string name="gcm_defaultSenderId" translatable="false">000000000000</string>
    <string name="google_storage_bucket" translatable="false">gamebase-sample-00000000.appspot.com</string>
    <string name="project_id" translatable="false">gamebase-sample-00000000</string>
    <string name="google_api_key" translatable="false">AbCd_AbCd_AbCd_AbCd_AbCd_AbCd_AbCd</string>
    <string name="google_app_id" translatable="false">1:000000000000:android:abcd0123abcd0123</string>
    <string name="default_web_client_id" translatable="false">000000000000-abcdabcdabcdabcdabcdabcdabcd.apps.googleusercontent.com</string>
</resources>
  • In the case of Unreal build, it is distributed by Gamebase Unreal SDK which included empty google-service-json.xml files, so please change it to the appropriate value for the game information.
    • 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

Facebook IdP

  • Declares App ID to initialize Facebook SDK.
    • It is better to configure so that the value refers to resources rather than directly declaring it.
    • This setting is not required at the moment as Gamebase SDK internally calls a function to initialize Facebook SDK.

AndroidManifest.xml

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

res/values/strings.xml

<resources>
    <!-- [Facebook] Facebook APP ID -->
    <string name="facebook_app_id">123456789012345</string>
</resources>

LINE IdP

  • As android:allowBackup="false" is declared in LINE SDK, Manifest merger might fail while building the application. If a build fails in this way, add tools:replace="android:allowBackup" declaration to the application tag.
<application
      tools:replace="android:allowBackup"
      ... >

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"

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 -->

        <!-- [LINE] Configurations begin -->
        <package android:name="jp.naver.line.android" />
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https" />
        </intent>
        <!-- [LINE] 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