This page informs you how to port and build Hive SDK when developing games with Android Studio Project.

Porting

For the Android development environment, follow the instructions below to add the Hive SDK to your development environment and perform the necessary setups and tasks.

Prerequisites

The minimum versions of Gradle, Android Gradle Plugin, and Kotlin Gradle Plugin required for each Hive SDK version are shown below.

Hive SDK Gradle Android Gradle Plugin Kotlin Gradle Plugin
≥ v4.15.2 < v4.15.6 v5.6.4 v3.6.4 v1.4.32
≥ v4.15.6 < v4.16.2 v6.1 v3.6.4 v1.5.10
≥ v4.16.2 < v4.21.0 v6.1.1 v4.0.0 v1.5.20
≥ v4.21.0 < v4.23.0.0 v6.1.1 v4.0.0 v1.6.20
≥ v23.0.0 v7.5 v7.4.2 v1.8.0

 

Setting Gradle

Add the following code to the My Project/gradle/wrapper/gradle-wrapper.properties to set Gradle versions. The code below is the example of setting up Gradle 6.1.1.

 

Configure Gradle Plugin

Add the following code in your project-level Gradle file (build.gradle) to set the Gradle plugin version. The codes below are the examples of setting up Android Gradle Plugin 4.0.0 and Kotlin Gradle Plugin 1.6.20.

 

Migrate to AndroidX

In accordance with the version update of Android Support Library, AndroidX is required to add your project from Hive SDK v4.13.0.

  1. Run the Android Studio.
  2. Click Refactor >; Migrate to AndroidX on the menu bar.
  3. References dependant by Android support library in your project are changed, and followings are added to gradle.properties.

* android.enableJetifier=true
* android.useAndroidX=true

Adding Java 1.8

Using Java 1.8 requires to add the following codes to the module-leveled build.gradle file from Hive SDK v4.14.4.

 

Add Hive SDK and external libraries to Gradle

Add the Hive SDK and external libraries to your Gradle file. If you specify the Hive SDK version to be used ($HIVE_SDK_VERSION) and the external libraries to be used, the external library version is automatically set to match the current Hive SDK version and then the external libraries are added. If you update the Hive SDK version, it automatically updates the compatible external library versions as well. You can also add the external libraries by entering the external library version manually, but this is no longer recommended.

  1. Add the repository to your project-level build.gradle file to import the external library.

  2. Add the Hive SDK and external libraries to the module-level build.gradle file. The below is an example build.gradle.

  The Hive SDK, Google extension, and Facebook extension include the following libraries.

  • com.com2us.android.hive:hive-sdk
    • com.com2us.android.hive:hive-core
    • com.com2us.android.hive:hive-protocol
    • com.com2us.android.hive:hive-service
      • com.com2us.android.hive:hive-service-google-base
    • com.com2us.android.hive:hive-ui
      • com.com2us.android.hive:hive-ui-languagepack
      • androidx.recyclerview:recyclerview
      • com.github.bumptech.glide:glide
    • org.jetbrains.kotlin:kotlin-reflect
    • org.jetbrains.kotlinx:kotlinx-coroutines-core
    • org.jetbrains.kotlinx:kotlinx-coroutines-android
    • androidx.lifecycle:lifecycle-runtime-ktx
    • androidx.lifecycle:lifecycle-viewmodel-ktx
    • androidx.lifecycle:lifecycle-livedata-ktx
  • com.com2us.android.hive:hive-authv4-provider-google-sign
    • com.google.android.gms:play-services-auth
  • com.com2us.android.hive:hive-authv4-provider-google-playgames
    • com.google.android.gms:play-services-games-v2
  • com.com2us.android.hive:hive-authv4-provider-facebook
    • com.facebook.android:facebook-core
    • com.facebook.android:facebook-common
    • com.facebook.android:facebook-login
    • com.facebook.android:facebook-share

 

Adding external libraries in distribution package

In the case of some libraries which are unavailable to use the latest version on Gradle or requires additional management, distribution package includes them with Hive SDK. Follow the instructions below to add external libraries.

  1. Set dependencies for the libs folder in your module-level build.gradle file.
  2. Add the external library (.aar/.jar) included in the distribution to the module-level libs folder. The list of external libraries included in the distribution is as follows.
    • mid-sdk-2.10.jar (add this when supporting QQ Idp sign in)
    • mta-sdk-2.0.0.jar (add this when supporting QQ or WeChat Idp sign in)
    • open_sdk_3.5.4.11_r3f56456_lite.jar (add this when supporting QQ Idp sign in)

 

Setting AndroidManifest.xml File

Input the following items manually in AndroidManifest.xml file.

  • Facebook settings
    • provider settings: Input the Facebook AppID in com.facebook.app.FacebookContentProvider as the value of android:authorities property.
      • Example: When Facebook AppID is 123456789,<provider android:authorities="com.facebook.app.FacebookContentProvider123456789" />;
    • meta-data settings: Input the Facebook AppID and Facebook Client Token(Required when using Facebook SDK v13 or higher) as the value of android:value property.
      • Example: When Facebook AppID is 123456789,
      • Example: When Facebook Client Token is 123456789,
  • Google Play Services settings
    • meta-data settings: Input the Google AppID as the value of android:value property.
      • Example: When Google AppID is 56789876,
        android:value="56789876"
  • For using custom URL scheme, check whether ApplicationId is added to &lt;data android:scheme=”” />;, which is the value of intent-filter property in the Main Activity.

 

Adding Hive SDK Configuration

Add res/raw/hive_config.xml file. Make sure to add it for running Hive SDK.
Shortcut to hive_config.xml file 

Android Activity Lifecycle

Implement the following codes to fit Android Lifecycle in the Main Activity. This implementation is essential to run Hive SDK.

 

From Hive SDK v4.15.8, the deferred deep link is available. If you want to use the deferred deep link features, please check the setting procedure below. Conversely, if you do not use the corresponding features, be sure to refer to the IMPORTANT section below.

 

  • The deferred deep link is supported only for Google Play Store on Android.
  • To share a link for inviting friends using Hive User Acquisition(UA), set up the deferred deep link. You can freely use either the existing method or the deferred deep link method.
  • Existing UA Friend Invite Link UA Friend Invite Link via deferred deep link
    Progress – When accessing the invitation link, the user enters the your self-hosted web page through the game installation and game execution UI

    – No other information is included in the invitation link

    – When accessing the invitation link, guides the user to the game installation (the user moves to the app market) and to the game execution without a web page

    – Information can be included in the invitation link (controlled by Hive SDK)

    Supported Platform – When inducing the game installation, each app market url can be arbitrarily implemented on the self-hosted web page – Supports Google Play Store only (available only when accessing through the Chrome browser)
  • When setting up a deferred deep link , the operation sequence of the Hive User Acquisition (UA) is as follows.
    1. User A shares a deferred deep link through an UA invite link.
    2. If User B, who received the invite link, clicks the link to run the app, the server analyzes the link information to confirm User B plays the game through the UA link that User A sent: Receiving information for reward compensation
    3. A deferred deep link is a single link. When User B doesn’t download the app, the link encourages the user to install the app. However, the link runs the app and sends the information of Users A and B to the Promotion Server if User B already has installed the app.
  • Set up deferred deep links on Hive Console
    1. Go to the Promotion >; App Settings of the Hive Console menu, and search an app for setting a deferred deep link. Click the app name and go to the Basic Settings page.
    2. Check the Android App ID at the App ID Settings section on the Basic Settings page.
    3. Fill in the blanks ― Normal, UA Invite, and SHA256 ― at the App ID Settings section as described below.
      • Normal: https://play.google.com/store/apps/details?id={app id}
      • UA Invite: market://details?id={app id}
      • SHA256: The SHA256 fingerprint is located in the Google console. (Google Play Console > Apps > Settings > App Integrity > App Signing)
      • Its content is used to configure and utilize the assetlinks.json file. For more information, see our Verify Android App Links guide.
    4. Enables the deferred deep link. (Hive console > Promotion > App Settings > App Search > UA Settings > Deferred Deep Link Use Settings – Use > Save)
  • Set the deferred deep link related contents in AndroidManifest.xml
  • When applying Hive v4.16.2 or later, refer to the following and add it to AndroidManifest.xml.

 

Adding Amazon Settings File

To get the item information from Appstore SDK when using Amazon billing, you need to add an encrypted key file to /assets. See Amazon Appstore guide and learn more about how to download and add the AppstoreAuthenticationKey.pem key.

 

When using Amazon notifications, the app must include a valid API key to receive messages. Refer to the Amazon console guide to generate an API key from the Amazon console and include it in the app as a /assets/api_key.txt file.

Adding VK Settings

  • Set the app id, issued from the vk console, in the /res/values/strings.xml file.

Adding Huawei Settings

  1. Adding agconnect-services.json
    • Add the agconnect-services.json file downloaded from the Huawei console to the Project folder.
  2. Projectbuild.gradle file configuration
    • Add AppGallery Connect plugin and Maven address.
  3. Appbuild.gradle file configuration
    • Please add library settings and plugins for Huawei authentication and billing.
  4. Obfuscation settings

Configure Facebook Cloud Game Build

Hive 4.16.1 supports Facebook Cloud Game platform.
Facebook Cloud Game builds is only supported for Android, not iOS. Facebook Cloud Game is only available in certain regions in the United States.
Served throughout the states like California, Texas and the states in the North Mid-Atlantic (as of October 2020, Massachusetts, New York, New Jersey, Connecticut, Rhode Island, Delaware, Pennsylvania, Maryland, Washington D.C., Virginia, West Virginia).

It is necessary to check whether your build is supported with Facebook and Com2uS Platform personnel. If you want to support the build, please contact Com2uS Platform Office. For more information, you can refer to the Cloud Game Homepage and Facebook Developers page.

Please check the following for Hive SDK settings for Facebook Cloud Game

  1. Library Settings in build.gradle
    Remove hive-service-extension-facebook from Setting Dependency for Hive SDK and External Library and use hive-service-extension-facebookCloudGame.

    • (Lower than Hive 4.16.2) hive-service-extension-facebookCloudGame requires facebook-gamingservices library.
    • (Hive 4.16.2 or Higher) hive-service-extension-facebookCloudGame already includes facebook-gamingservices and other Facebook libraries.
    • (Hive SDK v4 versions 23.0.0 or higher) hive-authv4-provider-facebook-cloudgame includes both facebook-gamingservices and other Facebook libraries.

    In addition, Facebook Cloud Game does not guarantee the normal operation of the external authentication and tracking libraries, so it requires the removal of the external library library declaration.

    • Remove hive-authv4-provider-google-signin and hive-authv4-provider-google-playgames.
    • Remove the declarations related to external authentication libraries such as Wechat, VK, etc.
    • Remove the declarations related to external tracking libraries such as Adjust, AppsFlyer, Singular, etc.
    • Remove the security module declaration
  2.  

  3. hive_config.xml settings
    For the apps that has provided the Facebook functions through the Hive SDK, there is no setting to be added for Facebook Cloud Game. Please maintain the existing hive_config.xml settings, in which Facebook settings like Facebook App ID are saved.
    For more details on hive_config.xml, please check the developer page.
  4.  

  5. Facebook console settings
    For normal SDK operation, register the following path in ‘Save file paths’ when registering game APK.

    The Location in Console Facebook console Apps Dashboard >; Games >; Upload Cloud Game >; Upload Game APK >; Save file paths
    Registration Details /data/data/{Your package name}/files/hive*/data/data/{Your package name}/shared_prefs/*
  6.  

  7. Other details for Facebook Cloud Games
    When APK is executed in the Facebook Cloud environment, it is similar to an emulator or a rooting environment (the file path is different from that of mobile, etc.), so the App Guard or the other security modules used in the game project may restrict the app operation. Please remove the security modules or check the related parts.
    (In the sample app for the Hive 4.16.2, the Facebook Cloud Game failed to be built when the security module was added.)

Add FirebaseAnalytics

After registering your app in the Firebase console, insert the issued google-services.json file into your project.
Add the following codes in your project-level Gradle file (build.gradle).

  • Add the dependencies for the Firebase Analytics in your module-level build.gradle file.
  • Configure ONE Store build

    1. Set the following in your project level build.gradle.
    2. Add the following to your module level build.gradle:

    Setting up a Google Play Games on PC build

    From the Hive SDK 4.16.2, Google Play Games on PC is officially supported.
    The Google Play Games on PC requires the confirmation for the build support from Google and Com2uS Platform Office. Please contact the Com2uS Platform Office for any build-related issues.
    If you support Google Play Games on PC, Google‘s PC environment emulator platform, please check the settings below.

    1. Library Settings in build.gradle

      Use hive-authv4-provider-google-playgames that is in Setting Dependency for Hive SDK and External Library. hive-authv4-provider-google-playgames already includes play-service-games-v2 library.

    2. hive_config.xml settings

      Refer to hive_config.xml settings and set playAppId and serverClientId in tags within <google> tags.

    3. Remove unused Android permissions

      Google Play Games on PC does not support the android.hardware.wifi.feature. If you are using the following permissions in the game, please remove them.

    Support Google login

    To support Google sign-in, not Google Play Games, you need the following settings in your module-level build.gradle file:

    Building

    Setting Gradle

    Enter the value of android >; defaultConfig >; applicationId as the same with the packageName value from AndroidManifest.xml file. The minSdkVersion of Hive SDK is 21.

    Shrink, Obfuscate, Optimize App

    R8 (ProGuard) Config File Settings

    To use the R8 compiler for optimizing an app, set the R8 config file by following guides.

    unity

    facebook

    google / admob/adkit

    line

    vk

    qq

    wechat

    adjust

    singular

    appsflyer

    huawei

    Glide

    amazon

    Configure Language Resource

    You can delete unused language resources to shrink your app. To delete unused language resources among the 16 languages supported by the Hive SDK, specify only the languages you actually want to use in the resConfigs property of the Android Gradle plugin. Any language resources not specified in this property are removed from the app. The following code shows how to restrict language resources to English and Korean.