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.
1 2 3 |
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip |
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.
1 2 3 4 5 6 7 8 |
buildscript { dependencies { classpath "com.android.tools.build:gradle:4.0.0" classpath "org.jetbrains.kotlin: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.
- Run the Android Studio.
- Click Refactor >; Migrate to AndroidX on the menu bar.
- 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.
1 2 3 4 5 6 7 8 |
android { ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } ... } |
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.
-
Add the repository to your project-level build.gradle file to import the external library.
123456789allprojects {repositories {google()mavenCentral()gradlePluginPortal()}} -
Add the Hive SDK and external libraries to the module-level build.gradle file. The below is an example build.gradle.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576dependencies {// Hive SDK BOM, e.g.: 23.0.0implementation(platform("com.com2us.android.hive:hive-sdk-bom:${project.HIVE_SDK_VERSION}"))// Hive SDKimplementation "com.com2us.android.hive:hive-sdk"// Analytics Provider, add only the providers you use.implementation "com.com2us.android.hive:hive-analytics-provider-adjust"implementation "com.com2us.android.hive:hive-analytics-provider-appsflyer"implementation "com.com2us.android.hive:hive-analytics-provider-firebase"implementation "com.com2us.android.hive:hive-analytics-provider-singular"// AuthV4 Device Management Serviceimplementation "com.com2us.android.hive:hive-authv4-device-management"// AuthV4 Google In-App Updateimplementation "com.com2us.android.hive:hive-authv4-google-inappupdate"// AuthV4 Google reCAPTCHAimplementation "com.com2us.android.hive:hive-authv4-google-recaptcha"// AuthV4 Real Name Verification for Chinaimplementation "com.com2us.android.hive:hive-authv4-real-name-verification"// AuthV4 Provider, add only the providers you use.implementation "com.com2us.android.hive:hive-authv4-provider-apple-signin"implementation "com.com2us.android.hive:hive-authv4-provider-facebook"implementation "com.com2us.android.hive:hive-authv4-provider-google-playgames"implementation "com.com2us.android.hive:hive-authv4-provider-google-signin"implementation "com.com2us.android.hive:hive-authv4-provider-hive-membership"implementation "com.com2us.android.hive:hive-authv4-provider-huawei"implementation "com.com2us.android.hive:hive-authv4-provider-line" // require minSdk 24implementation "com.com2us.android.hive:hive-authv4-provider-qq"implementation "com.com2us.android.hive:hive-authv4-provider-vk"implementation "com.com2us.android.hive:hive-authv4-provider-wechat"implementation "com.com2us.android.hive:hive-authv4-provider-weverse"// DataStoreimplementation "com.com2us.android.hive:hive-datastore"// IapV4, automatically included when you add a market.implementation "com.com2us.android.hive:hive-iapv4"// IapV4 Market, add only the markets you use.implementation "com.com2us.android.hive:hive-iapv4-market-amazon"implementation "com.com2us.android.hive:hive-iapv4-market-google"implementation "com.com2us.android.hive:hive-iapv4-market-huawei"implementation "com.com2us.android.hive:hive-iapv4-market-lebi"implementation "com.com2us.android.hive:hive-iapv4-market-onestore"implementation "com.com2us.android.hive:hive-iapv4-market-samsung"implementation "com.com2us.android.hive:hive-iapv4-market-hivestore"// Promotionimplementation "com.com2us.android.hive:hive-promotion"// Promotion Google In-App Reviewimplementation "com.com2us.android.hive:hive-promotion-google-inappreview"// Add if you use Promotion video features.implementation "com.com2us.android.hive:youtube-helper"// Push, Amazon Device Messagingimplementation "com.com2us.android.hive:hive-push-amazon-adm"// Push, Firebase Cloud Messagingimplementation "com.com2us.android.hive:hive-push-google-fcm"// Hercules Abusing Detectionimplementation "com.com2us.android.hive:hive-hercules"// Used for Google Install Referrer tracking.implementation "com.android.installreferrer:installreferrer"// Add if you are using HiveC2S, HiveV1.implementation "com.com2us.android.hive:hive-plugin-c2s"// Add if you are not developing in native environment.implementation "com.com2us.android.hive:hive-plugin-java"}
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.
- Set dependencies for the libs folder in your module-level build.gradle file.
1234dependencies {implementation fileTreeinclude: ['*.jar'], dir: 'libs')implementation fileTreeinclude: ['*.aar'], dir: 'libs')} - 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" />;
- Example: When Facebook AppID is 123456789,
- 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,
123<meta-dataandroid:name="com.facebook.sdk.ApplicationId"android:value="fb${facebookId}"/>; - Example: When Facebook Client Token is 123456789,
123<meta-dataandroid:name="com.facebook.sdk.ClientToken"android:value="fb${facebookClientToken}"/>;
- Example: When Facebook AppID is 123456789,
- provider settings: Input the Facebook AppID in com.facebook.app.FacebookContentProvider as the value of android:authorities property.
- 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"
- Example: When Google AppID is 56789876,
- meta-data settings: Input the Google AppID as the value of android:value property.
- For using custom URL scheme, check whether ApplicationId is added to <data android:scheme=”” />;, which is the value of intent-filter property in the Main Activity.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.com2us.hivesdk.normal.freefull.google.global.android.common"android:versionCode="2"android:versionName="4.0.0"android:installLocation="auto"xmlns:tools="http://schemas.android.com/tools"><uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/><uses-feature android:glEsVersion="0x00020000"/><uses-feature android:name="android.hardware.touchscreen"/><uses-featureandroid:name="android.hardware.touchscreen.multitouch"android:required="false"/><uses-featureandroid:name="android.hardware.touchscreen.multitouch.distinct"android:required="false"/><supports-screensandroid:anyDensity="true"android:largeScreens="true"android:normalScreens="true"android:smallScreens="true"android:xlargeScreens="true"/><applicationandroid:allowBackup="false"tools:replace="android:allowBackup"android:hardwareAccelerated="true"android:icon="@drawable/app_icon"android:label="@string/app_name"android:isGame="true"><activityandroid:label="@string/app_name"android:name="com.hive.sample.MainActivity"android:screenOrientation="sensor"android:launchMode="singleTask"android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDerection"><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter><!- for userengagement -><intent-filter><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="${applicationId}" /></intent-filter></activity><!- for Hive SDK Social begin -><provider android:authorities="com.facebook.app.FacebookContentProvider${facebookId}"android:name="com.facebook.FacebookContentProvider"android:exported="true" /><meta-dataandroid:name="com.facebook.sdk.ApplicationId"android:value="fb${facebookId}"/><meta-dataandroid:name="com.facebook.sdk.ClientToken"android:value="fb${facebookClientToken}"/><!- Social end -><!- Google Play Services -><meta-dataandroid:name="com.google.android.gms.games.APP_ID"android:value="${googleplayId}"/><!-- QQ Auth --><activity android:name="com.tencent.tauth.AuthActivity" android:launchMode="singleTask" android:noHistory="true"><intent-filter><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="tencent${qqAppId}" /></intent-filter></activity><!-- QQ Auth --></application></manifest>
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
@Override protected void onCreateBundle savedInstanceState) { super.onCreate(savedInstanceState); HiveActivity.onCreatethis, savedInstanceState); } @Override protected void onStart) { super.onStart(); HiveActivity.onStart(this); } @Override protected void onRestart) { super.onRestart(); HiveActivity.onRestart(this); } @Override protected void onResume) { super.onResume(); HiveActivity.onResume(this); } @Override protected void onPause) { HiveActivity.onPause(this); super.onPause(); } @Override protected void onStop) { HiveActivity.onStop(this); super.onStop(); } @Override protected void onDestroy) { HiveActivity.onDestroy(this); super.onDestroy(); } @Override public void onWindowFocusChangedboolean hasFocus) { super.onWindowFocusChanged(hasFocus); HiveActivity.onWindowFocusChangedthis, hasFocus); } @Override protected void onNewIntentIntent intent) { super.onNewIntent(intent); HiveActivity.onNewIntentthis, intent); } @Override protected void onActivityResultint requestCode, int resultCode, Intent data) { super.onActivityResultrequestCode, resultCode, data); HiveActivity.onActivityResultthis, requestCode, resultCode, data); } // Android SDK 6.0 (android-23) API over @TargetApi(23) @Override public void onRequestPermissionsResultint requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResultrequestCode, permissions, grantResults); HiveActivity.onRequestPermissionsResultthis, requestCode, permissions, grantResults); } |
Setting a Deferred Deep Link
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.
- User A shares a deferred deep link through an UA invite link.
- 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
- 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
- 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.
- Check the Android App ID at the App ID Settings section on the Basic Settings page.
- 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.
- 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.
123456789101112131415161718192021222324<!-- Deferred Deeplink Activity --><activity android:name="com.hive.userengagement.DeferredDeeplinkActivity" android:exported="true"><!-- Added when used on sandbox server --><intent-filter android:autoVerify="true"><action android:name="android.intent.action.VIEW"/><category android:name="android.intent.category.DEFAULT"/><category android:name="android.intent.category.BROWSABLE"/><data android:scheme="https" android:host="sandbox-promotion.qpyou.cn" android:pathPattern="/deeplink/${applicationId}/vid/.*"/></intent-filter><!-- Added when used on commercial servers --><intent-filter android:autoVerify="true"><action android:name="android.intent.action.VIEW"/><category android:name="android.intent.category.DEFAULT"/><category android:name="android.intent.category.BROWSABLE"/><data android:scheme="https" android:host="promotion.qpyou.cn" android:pathPattern="/deeplink/${applicationId}/vid/.*"/></intent-filter></activity>
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.
-
1<integer name="com_vk_sdk_AppId">your_app_id</integer>
Adding Huawei Settings
- Adding agconnect-services.json
- Add the agconnect-services.json file downloaded from the Huawei console to the Project folder.
- Project – build.gradle file configuration
- Add AppGallery Connect plugin and Maven address.
12345678910111213141516171819202122buildscript {repositories {google()jcenter()// Huawei HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}}dependencies {...// Huawei AppGallery Connect pluginclasspath 'com.huawei.agconnect:agcp:1.9.1.301'}}allprojects {repositories {google()jcenter()/// Huawei HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}}} - App – build.gradle file configuration
- Please add library settings and plugins for Huawei authentication and billing.
123456dependencies {// Huawei Dependencyimplementation "com.com2us.android.hive:hive-authv4-provider-huawei" // Huawei Authenticationimplementation "com.com2us.android.hive:hive-iapv4-market-huawei" // Huawei Billing}apply plugin: 'com.huawei.agconnect' - Obfuscation settings
- Please refer to the ‘huawei‘ setting part in the R8 (ProGuard) configuration file 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.
- 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445… (Skip) …// Hive SDK (Hive SDK v4 23.0.0 or higher)implementation "com.com2us.android.hive:hive-sdk"implementation "com.com2us.android.hive:hive-authv4-provider-facebook-cloudgame"// Remove standard Facebook integration.// implementation "com.com2us.android.hive:hive-authv4-provider-facebook// Remove all Google-related implementations for Facebook Cloud builds.// implementation "com.com2us.android.hive:hive-authv4-google-inappupdate"// implementation "com.com2us.android.hive:hive-authv4-google-recaptcha"// implementation "com.com2us.android.hive:hive-iapv4-market-google"// implementation "com.com2us.android.hive:hive-promotion-google-inappreview"// implementation "com.com2us.android.hive:hive-push-google-fcm"// implementation "com.android.installreferrer:installreferrer"… (Skip) …// Hive SDK (Hive SDK v4.16.4.0 or higher)implementation "com.com2us.android.hive:hive-sdk"implementation "com.com2us.android.hive:hive-service-extension-facebookCloudGame"// Must be removed from Facebook Cloud build// implementation "com.com2us.android.hive:hive-service-extension-google-signin"// Must be removed from Facebook Cloud build// implementation "com.com2us.android.hive:hive-service-extension-google-playgames"… (Skip) …// Hive SDK (Hive SDK v4.16.2 or higher, and lower than v4.16.4.0)implementation "com.com2us.android.hive:hive-sdk:{HIVE_SDK_VERSION}"implementation "com.com2us.android.hive:hive-service-extension-facebookCloudGame:{HIVE_SDK_VERSION}"// Must be removed from Facebook Cloud build// implementation "com.com2us.android.hive:hive-service-extension-google:{HIVE_SDK_VERSION}"… (Skip) …// Hive SDK (version below Hive SDK v4.16.2. Facebook SDK declaration is required)implementation ‘com.facebook.android:facebook-core:13.0.0'implementation ‘com.facebook.android:facebook-common:13.0.0'implementation 'com.facebook.android:facebook-login:13.0.0'implementation 'com.facebook.android:facebook-share:13.0.0'implementation 'com.facebook.android:facebook-gamingservices:13.0.0'… (Skip) … - 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. - 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/* - 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).
1 2 3 4 5 6 |
buildscript { dependencies { ... classpath 'com.google.gms:google-services:4.3.14' } } |
1 2 3 4 5 6 |
dependencies { implementation "com.com2us.android.hive:hive-analytics-provider-firebase" } // Add the following codes after the bottom of build.gradle. apply plugin: 'com.google.gms.google-services' |
Configure ONE Store build
- Set the following in your project level build.gradle.
12345678allprojects {repositories {...// only for OneStoremaven { url 'https://repo.onestore.co.kr/repository/onestore-sdk-public' }...}} - Add the following to your module level build.gradle:
12345dependencies {...implementation "com.onestorecorp.sdk:sdk-iap"...}
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.
-
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.
12345… (skip) …// Required for the Play Games on PC buildimplementation "com.com2us.android.hive:hive-authv4-provider-google-playgames"… (skip) … -
hive_config.xml settings
Refer to hive_config.xml settings and set playAppId and serverClientId in
tags within <google> tags. -
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.
12<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/><uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
Support Google login
To support Google sign-in, not Google Play Games, you need the following settings in your module-level build.gradle file:
1 2 3 4 5 6 7 8 9 |
// If the Google modules that supports Google Play Games login is included as shown below, remove that modules. // implementation "com.com2us.android.hive:hive-service-extension-google:$HIVE_SDK_VERSION" // implementation "com.com2us.android.hive:hive-service-extension-googlev2:$HIVE_SDK_VERSION" // implementation "com.com2us.android.hive:hive-service-extension-google-playgames:$HIVE_SDK_VERSION" // implementation "com.com2us.android.hive:hive-service-extension-google-signin:$HIVE_SDK_VERSION" // implementation "com.com2us.android.hive:hive-authv4-provider-google-playgames" // Add a dependency with Google login. implementation "com.com2us.android.hive:hive-authv4-provider-google-signin" |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
android { compileSdkVersion 31 buildToolsVersion "31.0.0" … defaultConfig { applicationId "hive.example.game.com.gameapp" minSdkVersion 21 targetSdkVersion 31 versionCode 1 versionName "1.0" // Facebook AppId to use in Application. ${facebookId} in the AndroidManifest.xml file are replaced with the values below. manifestPlaceholders = [facebookId:"123456789"] // Facebook Client Token to use in Application. ${facebookClientToken} in the AndroidManifest.xml file are replaced with the values below. manifestPlaceholders += [facebookClientToken:"123456789"] // PGS(Google Play) AppId to use in Application. ${googleplayId} in the AndroidManifest.xml file are replaced with the values below. manifestPlaceholders += [googleplayId:"123456789"] // QQ AppId to use in Application. ${qqAppId} in the AndroidManifest.xml file are replaced with the values below. manifestPlaceholders += [qqAppId:"123456789"] compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } … } |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
-keep class com.google.android.material.** { *; } -dontwarn com.google.android.material.** -dontnote com.google.android.material.** -dontwarn androidx.** -keep class androidx.** { *; } -keep interface androidx.** { *; } # ORIG/KS Interface -keep class com.hive.** { *; } # KS -keep class com.gcp.** { *; } # C2S -keep class com.com2us.** { *; } |
unity
1 2 3 |
-keep class com.android.** { *; } -keep class com.unity3d.** { *; } |
1 2 |
-keep class com.facebook.** { *; } |
google / admob/adkit
1 2 3 4 5 |
-keep class com.google.** { *; } -keepattributes *Annotation* -dontobfuscate |
line
1 2 3 4 5 6 |
-keepparameternames -renamesourcefileattribute SourceFile -keepattributes *Annotation*, Signature, InnerClasses, SourceFile, LineNumberTable, EnclosingMethod -dontobfuscate -dontwarn java.lang.invoke.* |
vk
1 2 3 4 5 6 7 |
-keep class com.vk.** { *; } -dontwarn org.seamless. -dontwarn org.eclipse.jetty.** -dontwarn org.fourthline.** -dontshrink -dontoptimize |
1 2 |
-keep class * extends android.app.Dialog |
1 2 3 4 |
-keep class com.tencent.mm.opensdk.** { *; } -keep class com.tencent.wxop.** { *; } -keep class com.tencent.mm.sdk.** { *; } |
adjust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
-keep class com.adjust.sdk.** { *; } # Include when your app is uploaded on Google Play Store -keep class com.google.android.gms.common.ConnectionResult { int SUCCESS; } # Include when your app is uploaded on Google Play Store -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient { com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context); } # Include when your app is uploaded on Google Play Store -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { java.lang.String getId(); boolean isLimitAdTrackingEnabled(); } -keep public class com.android.installreferrer.** { *; } |
singular
1 2 3 |
-keep class com.singular.sdk.** { *; } -keep public class com.android.installreferrer.** { *; } |
appsflyer
1 2 |
-keep public class com.android.installreferrer.** { *; } |
huawei
1 2 3 4 5 6 7 8 9 10 11 |
-ignorewarnings -ignorewarnings -keepattributes *Annotation* -keepattributes Exceptions -keepattributes InnerClasses -keepattributes Signature -keepattributes SourceFile,LineNumberTable -keep class com.huawei.hianalytics.**{*;} -keep class com.huawei.updatesdk.**{*;} -keep class com.huawei.hms.**{*;} |
Glide
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
-keep public class * implements com.bumptech.glide.module.GlideModule -keep class * extends com.bumptech.glide.module.AppGlideModule { <init>;(...); } -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { **[] $VALUES; public *; } -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { *** rewind(); } # for DexGuard only -keepresourcexmlelements manifest/application/meta-data@value=GlideModule |
amazon
1 2 3 4 |
-dontwarn com.amazon.** -keep class com.amazon.** {*;} -keepattributes *Annotation* |
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.
1 2 3 4 5 6 7 8 |
android { defaultConfig { ... resConfigs "en", "ko" } } |