跳轉至

Android

本頁面指導如何設置 Hive SDK Android 付款功能。

Hive 控制台配置

要使用 Hive SDK 计费,您需要首先在 Hive 控制台计费中配置 支付提供商设置,例如密钥值注册和市场链接。

Note

有关更多详细信息,请参阅 Google 市场帐户注册

添加市場

您需要將相應的外部庫添加到模塊級別的 build.gradle 文件中。僅添加您將使用的市場(支付提供者)。

以下是將外部庫添加到模塊級build.gradle文件的示例。

dependencies {
   // IapV4, will be automatically included when adding the Market below.
   implementation "com.com2us.android.hive:hive-iapv4"

   // IapV4 Market, add only the Market you are using.

   // Amazon
   implementation "com.com2us.android.hive:hive-iapv4-market-amazon"

   // Google
   implementation "com.com2us.android.hive:hive-iapv4-market-google"

   // Huawei
   implementation "com.com2us.android.hive:hive-iapv4-market-huawei"

   // Lebi
   implementation "com.com2us.android.hive:hive-iapv4-market-lebi"

   // ONEStore
   implementation "com.com2us.android.hive:hive-iapv4-market-onestore"

   // Samsung
   implementation "com.com2us.android.hive:hive-iapv4-market-samsung"

   // Hive Store
   implementation "com.com2us.android.hive:hive-iapv4-market-hivestore"
}

按市場的額外設置

根據市場的不同,需要額外的設置。

華為支付設置

本節提供使用華為支付的設置說明。


  1. 添加agconnect-services.json
    • 将从华为控制台下载的agconnect-services.json文件添加到项目文件夹中。
  2. 项目 - build.gradle 文件配置
    • 添加 AppGallery Connect 插件和 Maven 地址。
      buildscript {
          repositories {
              google()
              jcenter()
              // 华为 HMS Core SDK。
              maven {url 'https://developer.huawei.com/repo/'}
          }
          dependencies {
              ...
              // 华为 AppGallery Connect 插件
              classpath 'com.huawei.agconnect:agcp:1.9.1.301'
          }
      }
      allprojects {
          repositories {
              google()
              jcenter()
              /// 华为 HMS Core SDK。
              maven {url 'https://developer.huawei.com/repo/'}
          }
      }  
      
  3. 应用 - build.gradle 文件配置
    • 添加华为库和插件。
      dependencies {
          // 华为市场
          implementation "com.com2us.android.hive:hive-iapv4-market-huawei"
      }
      apply plugin: 'com.huawei.agconnect'
      

Samsung GalaxyStore 付款設置

本節提供有關配置三星 GalaxyStore 付款的說明。


  1. 在模塊級的 build.gradle 文件中,設置 libs 文件夾的依賴。

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation fileTree(include: ['*.aar'], dir: 'libs')
    }
    
  2. 將外部庫 samsung_iap_sdk-v6.1.aar 從 Hive SDK 發行版本添加到模塊級 libs 文件夾。

在模組級別的 build.gradle 文件中,移除 QQ、微信、華為和 Hive Lebi 庫。如果這些庫包含在應用程序構建中,則應用程序可能會在 Galaxy Store 審核過程中被拒絕

```groovy
dependencies {
// List of libraries to exclude for Galaxy Store distribution build
implementation "com.com2us.android.hive:hive-authv4-provider-qq" 
implementation "com.com2us.android.hive:hive-authv4-provider-wechat"
implementation "com.com2us.android.hive:hive-authv4-provider-huawei"
implementation "com.com2us.android.hive:hive-iapv4-market-lebi"
}
```
  1. 移除以下庫文件從構建中。如果這些文件包含在應用構建中,應用可能會在Galaxy Store審核過程中被拒絕

    • mid-sdk-{VERSION_INFO}.jar
    • mta-sdk-{VERSION_INFO}.jar
    • open_sdk_{VERSION_INFO}_lite.jar

一商店支付設置

在项目级build.gradle中设置以下内容。

allprojects {
    repositories {
        ...
        // only for OneStore
        maven { url 'https://repo.onestore.co.kr/repository/onestore-sdk-public' }
        ...
    }
}
Note

如果您使用的是 ONE Store SDK V21,您可以在 ONE Store 全球平台 上分發您的應用程式。欲了解更多資訊,請參考 ONE Store 全球部署指南全球商店部署的測試選項設置