Flutter Android。无法从Google Play获取应用内产品

6 人关注

我目前面临一个问题,我的Flutter应用程序无法从Google Play商店获取可消费的应用内产品。然而,我的应用程序能够从苹果应用商店获取所有产品。

我无法确定我错过了什么步骤,或者是什么导致我所有的产品ID都找不到。我正在使用flutter的 在应用中购买 模块,以促进应用内购买。

对于安卓系统,以下是我所采取的设置步骤。

  • I've setup my Google Play Console and Developer Account
  • Completed all the tasks in the Set up your app section
  • Generated a keystore file to sign my app keytool -genkey -v -keystore c:\Users\USER_NAME\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
  • Created a file named /android/key.properties that contains a reference to my keystore file. The contents of this file look like the following:
  • storePassword=<password from previous step>
    keyPassword=<password from previous step>
    keyAlias=key
    storeFile=<location of the key store file, such as /Users/<user name>/key.jks>
    
  • Configured my build.gradle file to include the following
  • def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    android {
       signingConfigs {
           release {
               keyAlias keystoreProperties['keyAlias']
               keyPassword keystoreProperties['keyPassword']
               storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
               storePassword keystoreProperties['storePassword']
       buildTypes {
           release {
               signingConfig signingConfigs.release
    
  • 创建了一个应用程序捆绑包,并在封闭轨道flutter build appbundle --flavor prod --release下发布了它。在上传工件时,我还让google在我的应用程序上签名 "Google signing the app"。

  • 我已经添加了一个与开发者账户无关的测试者,并在 "许可测试 "下添加了相同的电子邮件,许可响应为 "RESPOND_NORMALLY"。

  • 我还创建了三个可消耗的产品,并将它们设置为活动。

    以下是我获取产品的代码

      List<String> _kProductIds = <String>[
        'my_app_premium_year_c',
        'my_app_premium_month_c',
        'my_app_premium_week_c'
    final ProductDetailsResponse productResponse =
            await InAppPurchase.instance.queryProductDetails(_kProductIds.toSet());
    

    下面显示了我得到的意外结果。那就是我所有的产品都在notFoundIDs列表中。【替换代码5

    I expect the notFoundIDs list to be empty when including the following code print("ProductIDs not found: ${productResponse.notFoundIDs}");

    如果有任何提示或建议,我们将不胜感激。

    编辑:下面的截图显示了我在谷歌控制台的应用内产品页面。为了保护我的隐私,我掩盖了某些标识符,但是截图中的产品ID与我代码中的产品ID一致。

  •