Android SDK

This document explains how to use the GAMEPOT Android SDK to develop games for Android. By installing the SDK and configuring the environment, you can integrate the game with the dashboard.

System Requirements

The system requirements for using the GAMEPOT Android SDK are as follows:

  • Minimum Requirements: Android Level 24 or higher (If you need support for lower versions of Android, please contact [email protected].)

SDK Installation and Environment Configuration

After installing the Android SDK, you can configure the environment to integrate the GAMEPOT dashboard with your game and use the necessary features for game development.

The GAMEPOT SDK supports the following languages:

  • Korean, English, Italian, Thai, Vietnamese, Japanese, Chinese (Simplified/Traditional), Indonesian, German, Spanish, French.

When running the app, the SDK will display the supported language based on the device’s language settings. If a language is not supported, it will default to English.

SDK Installation

To install the GAMEPOT Android SDK and set up the project, follow these steps:

  1. Log in to the dashboard with an administrator account.

  2. Add the Nbase SDK to the bundle.gradle or bundle.gradle.kts file.

  3. Starting from GAMEPOT 3.0, external libraries can be easily integrated through Gradle settings.

Kotlin Gradle Configuration

  1. Add the following definition to the settings.gradle.kts file of the project.

dependencyResolutionManagement {
    repositories {
        ...
        google()
        // nbase repo
        maven(url = "https://repo.nbase.io/repository/nbase-releases")
    }
}
  1. Add SDK dependencies to the build.gradle.kts file of the project (Module: app).

dependencies {
...
    implementation("com.google.code.gson:gson:2.10")
    implementation("androidx.security:security-crypto:1.0.0")
    implementation("com.apollographql.apollo3:apollo-runtime:4.0.0-beta.4")
    implementation("io.socket:socket.io-client:2.1.0")
    implementation("io.nbase:nbasesdk:3.0.78")
}

Example: If using Google login and Google Play Store payment.

 dependencies {
...
    implementation("com.google.code.gson:gson:2.10")
    implementation("androidx.security:security-crypto:1.0.0")
    implementation("com.apollographql.apollo3:apollo-runtime:4.0.0-beta.4")
    implementation("io.socket:socket.io-client:2.1.0")
    implementation("io.nbase:nbasesdk:3.0.78")
    implementation("io.nbase:nbase-adapter-provider-google:3.0.4")
    implementation("io.nbase:nbase-adapter-billing-googleplay:3.0.3")
    implementation("com.google.android.gms:play-services-auth:20.7.0")
    implementation("com.android.billingclient:billing-ktx:6.1.0")
}

Java Gradle Configuration

  1. Add the definition to the build.gradle file of the project (Module: project).

allprojects {
    repositories {
        ...
        google()
        // nbase repo
        maven { url "https://repo.nbase.io/repository/nbase-releases" }
    }
}

2. 프로젝트에 (Module : app)의 build.gradle 파일에 SDK 종속성을 추가합니다.
```Groovy
dependencies {
...
    implementation("com.google.code.gson:gson:2.10")
    implementation("androidx.security:security-crypto:1.0.0")
    implementation("com.apollographql.apollo3:apollo-runtime:4.0.0-beta.4")
    implementation("io.socket:socket.io-client:2.1.0")
    implementation("io.nbase:nbasesdk:3.0.78")
}

Example: If using Google login and Google Play Store payment.

 dependencies {
...
    implementation("com.google.code.gson:gson:2.10")
    implementation("androidx.security:security-crypto:1.0.0")
    implementation("com.apollographql.apollo3:apollo-runtime:4.0.0-beta.4")
    implementation("io.socket:socket.io-client:2.1.0")
    implementation("io.nbase:nbasesdk:3.0.78")
    implementation("io.nbase:nbase-adapter-provider-google:3.0.4")
    implementation("io.nbase:nbase-adapter-billing-googleplay:3.0.3")
    implementation("com.google.android.gms:play-services-auth:20.7.0")
    implementation("com.android.billingclient:billing-ktx:6.1.0")
}

Library List

Name
Version
Type
Dependeny modules

io.nbase:nbasesdk

3.0.78

GAMEPOT Base Module

X

io.nbase:nbase-adapter-provider-google

3.0.4

Google Login

com.google.android.gms:play-services-auth:20.7.0

io.nbase:nbase-adapter-provider-apple

3.0.3

Apple Login

io.nbase:nbase-adapter-provider-facebook

3.0.2

Facebook Login

com.facebook.android:facebook-login:latest.release

io.nbase:nbase-adapter-provider-naver

3.0.1

NAVER Login

io.nbase:nbase-adapter-provider-line

3.0.1

Line Login

io.nbase:nbase-adapter-provider-x

3.0.1

X Login

io.nbase:nbase-adapter-billing-googleplay

3.0.3

Google Store

com.android.billingclient:billing-ktx:6.1.0

io.nbase:nbase-adapter-billing-one

3.0.1

ONEStore

io.nbase:nbase-adapter-billing-galaxy

3.0.1

Galaxy Store

io.nbase:nbase-adapter-billing-amazon

3.0.1

Amazon Store

Email and guest login are applied to the base module.

Preparation Steps

  1. You can copy the Project ID and Project Key from the Dashboard → Project Settings.

  2. Environment settings for login, store, and integration can all be added/modified from the Dashboard → Project Settings.

  3. For each login method, refer to the [Login Authentication Settings], configure it in the console, and add it to the dashboard.

  4. For in-app payments, refer to the [Store Settings], configure it in the console, and add it to the dashboard.

  5. Please register items for each store for in-app payments. Add them in the Dashboard → Payment → In-App section.

Initialization

To initialize, add the following code to the object used in the first scene that loads when the game starts.

import com.nbase.sdk.NBase
import com.nbase.sdk.Store

 NBase.initialize(activity, projectId, projectKey, [StoreId], [language], [region]) { init, e ->
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", init)
    }
}
  • Parameter

Key
Description
Required

projectId

Dashboard → Project Settings

O

projectKey

Dashboard → Project Settings

O

storeId

Refer to the table below

O

language

Language (en,ko,jp...)

O

region

Region (kr, jp, sg, us, eu, preview)

O

Key
Description

Store.GOOGLE.ToString()

Google Store

Store.ONE.ToString()

ONEStore

Store.GALAXY.ToString()

Galaxy Store

Store.AMAZON.ToString()

Amazon Store

Store.HUAWEI.ToString()

Huawei Store

  • Callback

Key
Type
Description

status

Boolean

Status

language

String

Language

country

String

Country

remote_ip

String

IP

platform

String

Platform

sandbox

Boolean

Sandbox Mode

Login

To use the SDK login functionality that is triggered when the login button is clicked, depending on the login UI implemented by the developer, please use the following code.

import com.nbase.sdk.Provider

NBase.signIn(activity, Provider.GOOGLE.toString()) { user, e -> 
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", user)
    }
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    NBase.onActivityResult(requestCode, resultCode, data)
}
  • Parameter

Key
Description

Provider.GOOGLE.ToString()

Google

Provider.ANONYMOUS.ToString()

Guest

Provider.FACEBOOK.ToString()

Facebook

Provider.APPLE.ToString()

Apple

Provider.KAKAO.ToString()

Kakao

Provider.PLAYGAME.ToString()

Play Game

Provider.STEAM.ToString()

Steam

Provider.X.ToString()

X

Provider.LINE.ToString()

Line

Provider.NAVER.ToString()

NAVER

Provider.GITHUB.ToString()

Github

Provider.MICROSOFT.ToString()

Microsoft

Provider.HUAWEI.ToString()

Huawei

  • Callback

Key
Type
Description

id

String

User ID

socialId

String

Social ID

name

String

Name

nickname

String

Nickname

email

String

Email

token

String

Token

age

Int

Age

birth

String

Date of Birth

sex

String

Gender

profile

String

Profile URL

mobile

String

Phone Number

customField

String

Custom Field

Automatic Login (Optional)

After initialization, the system attempts automatic login using the last authentication method the user logged in with.

NBase.signInLastLoggedIn(activity) { user, e ->
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", user)
    }
}

Self-ID and Password Authentication (Optional)

This authentication method allows users to log in using their email address and password. It performs user authentication based on the user's email address and password. This feature plays an important role in traditional email/password-based authentication systems.

NBase.signInWithPassword(activity, username, password) { user, e ->
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", user)
    }
}

Login with Credentials (Optional)

This feature is used to handle user login using authentication credentials obtained through various methods (such as email and password, social media accounts, phone numbers, etc.). It facilitates the implementation of diverse authentication methods and enables login to Gamepot.

NBase.signInWithCredential(activity, Provider.GOOGLE.ToString(), providerToken) { user, e ->
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", user)
    }
}

Logout

To use the SDK logout function, please use the code below.

NBase.signOut() { status, e ->
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", status)
    }
}
  • Callback

Key
Type
Description

status

Boolean

Success Status

Payment

Before making a payment, you must configure the settings for each store according to the store's requirements in the [Store Settings]. Additionally, if items have not been added in the Dashboard → Payment → In-App section, the error 'ProductID not found' will occur.

Fetch In-App Information

When making a payment, you need to display payment information and local currency details on the screen. You can retrieve the current payment currency, name, and other details using the functions below. If the information is not fetched correctly, please check the console settings.

import com.nbase.sdk.Store

NBase.getProductItems() {products, e -> 
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        // In-app Item Information
        Log.e("NBase", products)
    }
}
  • Callback

Key
Type
Description

id

String

ID

productName

String

Product Name

price

Float

Product Price

productId

String

Product Unique ID

productType

String

Product Type

productDescription

String

Product Description

currency

String

Currency Unit

Payment Request

You can request a payment using the productId from the fetched in-app information.

import com.nbase.sdk.Store

NBase.purchase(activity, Store.GOOGLE, [productId], [metadata], [options]) { purchase, e -> 
    if (e != null) {
        Log.e("NBase", e.message)
    } else {
        Log.e("NBase", purchase)
    }
}
  • Parameter

Key
Description
Required

ProductId

Product ID (Dashboard → Payment → In-App Items)

O

Metadata

Metadata

X

Options

Payment Option Features

X

Key
Description

Store.GOOGLE.ToString()

Google Store

Store.ONE.ToString()

ONEStore

Store.GALAXY.ToString()

Galaxy Store

Store.AMAZON.ToString()

Amazon Store

Store.HUAWEI.ToString()

Huawei Store

  • Callback

Key
Type
Description

id

String

ID

orderId

String

Oder ID

storeId

String

Store ID

productId

String

Product ID

billingKey

String

Billing Key

signature

String

Signature

originalJson

String

Original JSON

developerPayload

String

Developer Payload

packageName

String

Package Name

isAcknowledged

bool

Confirmation Status

purchaseState

String

Purchase Status

purchaseTime

String

Purchase Time

quantity

String

Quantity

recurringState

String

Subscription Status

currency

String

Currency

country

String

Country

paymentId

String

Payment ID

price

Float

Price

iapVersion

String

In-app Billing Version

playerId

String

Player ID

serverId

String

Server ID

level

Int

Level

userdata

String

User Data

metadata

String

Metadata

options

String

Option

authCode

String

Authentication Code

Troubleshooting

Q. An error occurs on Android with the following message:

Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.security.crypto.MasterKeys" on path: DexPathList[[zip file "/data/app/~~KKBtt9efgPjpqDSP6o3P1g==/com.nbase.je_beta-6fz3RrA1gqu27fSFW0ehcQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~KKBtt9efgPjpqDSP6o3P1g==/com.nbase.je_beta-6fz3RrA1gqu27fSFW0ehcQ==/lib/arm64, /system/lib64, /system/system_ext/lib64]]

A. This error occurs because the MasterKeys class cannot be found. You need to add the following code to the build.gradle or build.gradle.kts file.

implementation("androidx.security:security-crypto:1.0.0")

Q. The following error occurs during Google login:

10: Developer console is not set up correctly.

A. You need to verify that the OAuth 2.0 Client ID and Client Secret of the web application registered in the Google Cloud Console are correctly entered in the GAMEPOT dashboard.

Q. The following error occurs during Google login:

16: Cannot find a matching credential.

A. This error can also occur if the package registered in the Google Cloud Console for OAuth 2.0 Android and the app's SHA-1 value do not match.

Last updated