Android
This guide provides instructions for setting up the authentication feature in the Hive SDK on Android.
Adding features¶
You need to add the external libraries corresponding to the module-level build.gradle file. Only add the authentication features you will use.
Below is an example of adding external libraries to the module-level build.gradle file.
dependencies {
// Feature-specific settings. Add only the features you are using.
// AuthV4 Device Management Service
implementation "com.com2us.android.hive:hive-authv4-device-management"
// AuthV4 Google In-App Update
implementation "com.com2us.android.hive:hive-authv4-google-inappupdate"
// AuthV4 Google reCAPTCHA
implementation "com.com2us.android.hive:hive-authv4-google-recaptcha"
// AuthV4 Real Name Verification (China)
implementation "com.com2us.android.hive:hive-authv4-real-name-verification"
}
Add IdP¶
Add external libraries to the module-level build.gradle file. Only add the IdP you will use.
Below is an example of adding external libraries to the module-level build.gradle file. The guest login feature can be used without adding any libraries.
dependencies {
// IdP-specific settings. Add only the IdPs you are using.
// Apple Login
implementation "com.com2us.android.hive:hive-authv4-provider-apple-signin"
// Facebook Login
implementation "com.com2us.android.hive:hive-authv4-provider-facebook"
// Google Play Games Login
// `hive-authv4-provider-google-playgames` includes the `play-service-games-v2` library.
implementation "com.com2us.android.hive:hive-authv4-provider-google-playgames"
// Google Login
// Google Play Games Login and Google Login are different login methods.
implementation "com.com2us.android.hive:hive-authv4-provider-google-signin"
// Hive Membership Login
implementation "com.com2us.android.hive:hive-authv4-provider-hive-membership"
// Huawei Login
implementation "com.com2us.android.hive:hive-authv4-provider-huawei"
// LINE Login
// To apply the LINE library, minSdkVersion 24 or higher is required.
implementation "com.com2us.android.hive:hive-authv4-provider-line"
// QQ Login
implementation "com.com2us.android.hive:hive-authv4-provider-qq"
// Steam Login
implementation "com.com2us.android.hive:hive-authv4-provider-steam"
// VK library requires targetSdkVersion 32 or higher.
implementation "com.com2us.android.hive:hive-authv4-provider-vk"
// WeChat Login
implementation "com.com2us.android.hive:hive-authv4-provider-wechat"
// Weverse Login
implementation
// X Login
implementation "com.com2us.android.hive:hive-authv4-provider-x"
// Telegram Login
implementation "com.com2us.android.hive:hive-authv4-provider-telegram"
}
Enter the key values for each IdP in hive_config.xml¶
Enter the key values obtained from each IdP console in hive_config.xml. For more details, refer to Authentication Prerequisites.
Additional settings by IdP¶
Additional configuration is required depending on the IdP.
Google play games sign-in IdP settings¶
To use Google Play Games login, set it up as follows.
AndroidManifest.xml settings¶
This is the configuration for Google Play Services. It is the required value for Google Play Games login setup.
<manifest>
<application>
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/game_services_project_id"/>
</application>
</manifest>
Facebook IdP configuration¶
To use Facebook login, configure AndroidManifest.xml according to the instructions below.
First, set up the FacebookContentProvider for sharing links, images, or videos in the app. Enter the Facebook AppID by appending it to the com.facebook.app.FacebookContentProvider
as the value of the android:authorities
attribute. The Facebook AppID can be found in the app ID for the game app registered in the Facebook console.
Example: When the FacebookAppID is 123456789
<provider android:authorities="com.facebook.app.FacebookContentProvider123456789"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
Warning
To enable Facebook sharing, declaring the FacebookContentProvider
permission will prevent simultaneous installation of market-specific Android builds (e.g., Google Play Store, One Store).
If you are not using Facebook sharing, please refer to the troubleshooting guide to remove the declaration of the FacebookContentProvider
permission.
Add settings for Facebook AppId and client token configuration (required for Facebook v13 and above). For the Facebook client token, refer to App Settings > Advanced Settings in the Facebook console.
Example: When the FacebookAppID is 123456789
Example: When the Facebook Client Token is 123456789
Note
You can also set the Facebook AppId and client token in the string.xml file. In this case, the fb
prefix is not required when setting android:value
. For more details, check here.
QQ/wechat IdP configuration¶
If you support QQ or WeChat IdP, please apply the following additional content.
Set the dependency for the libs folder in the module-level build.gradle file.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.aar'], dir: 'libs')
}
Add external libraries from the Hive SDK distribution version in the module-level libs folder(.aar/.jar). The list of external libraries included in the distribution version is as follows.
- mid-sdk-2.10.jar (Add this file when supporting QQ IdP login)
- mta-sdk-2.0.0.jar (Add this file when supporting QQ or Wechat IdP login)
- open_sdk_3.5.4.11_r3f56456_lite.jar (Add this file when supporting QQ IdP login)
VK IdP configuration¶
- Set the app id issued from the VK console in the /res/values/strings.xml file.
Warning
The login method provided by VK IdP has changed, and as of June 2024, if you register a new app setting in the VK console, you will not be able to use VK login provided by the Hive SDK. The changed login method is expected to be supported in Hive SDK v4 25.2.0 or higher around April to May 2025.
Huawei IdP configuration¶
- Add agconnect-services.json
- Add the agconnect-services.json file downloaded from the Huawei console to the Project folder.
- Configure the Project - build.gradle file
- Add the AppGallery Connect plugin and Maven address.
buildscript { repositories { google() jcenter() // Huawei HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} } dependencies { ... // Huawei AppGallery Connect plugin classpath 'com.huawei.agconnect:agcp:1.9.1.301' } } allprojects { repositories { google() jcenter() /// Huawei HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} } }
- Add the AppGallery Connect plugin and Maven address.
- Configure the App - build.gradle file
- Add Huawei authentication library and plugin.