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

发布于 2025-01-17 16:27:20 字数 2861 浏览 2 评论 0原文

目前,我面临着一个问题,即我的颤抖应用程序无法从Google Play商店获取可消耗的应用程序内产品。但是,我的应用程序能够从Apple App Store中获取所有产品。

我无法识别我缺少的步骤或什么是导致所有产品ID的原因。我正在使用Flutter的 in_app_purchase 模块以便利应用。

对于Android,这是我采取的设置步骤。

  1. 我已经设置了我的Google Play控制台和开发人员帐户
  2. 完成了设置中的所有任务,您的应用程序部分
  3. 生成了一个密钥库文件,以签署我的应用程序 KEYTOOL -GENKEY -V -KEYSTORE C:\ USER \ USER_NAME \ key.jks -StoreType jks -keyalg rsa -keysize 2048 -Vality -vality 10000 -Alias key
  4. 创建一个名为/android/key.properties的文件包含对我的密钥库文件的引用。该文件的内容看起来如下:
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>
  1. 配置我的build.gradle文件以包括以下
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
       }
   }
}
  1. 创建了一个应用程序捆绑包并在封闭的曲目flutter build appbundle -flavor -flavor -prod -rease -rease 。我也让Google签署我的应用程序“ Google签署该应用程序”时,当我上传文物时。

  2. 我添加了一个与开发人员帐户无关的测试仪,并在“许可测试”下添加了与许可响应“响应”的“响应”。

  3. 我还创建了三个消耗品并将它们设置为活动。

以下显示了获取产品的代码,

  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列表中。 [my_app_prem_year_c,my_app_premium_month_c,my_app_premium_week_c]

我希望NotFoundIDS列表在包含以下代码时会为空 print(“找不到prouctiDs:$ {productresponse.notfoundids}”);

任何提示或建议都将不胜感激。

编辑:以下屏幕截图在Google控制台上显示我的应用程序内产品页面。我已经介绍了某些标识符以保护我的隐私,但是屏幕快照中的产品ID与我的代码中的产品ID匹配。

以下屏幕截图显示我的应用在Alpha,闭合曲目下发布。

I'm currently facing an issue where my Flutter application is unable to fetch consumable in-app products from Google Play store. However, my application is able to fetch all products from the Apple app store.

I can't identify what step I'm missing or what is causing all of my product ids to be not found. I'm using flutter's in_app_purchase module to facilitate in app purchases.

For Android, here are the setup steps I've taken.

  1. I've setup my Google Play Console and Developer Account
  2. Completed all the tasks in the Set up your app section
  3. 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
  4. 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>
  1. 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
       }
   }
}
  1. Created a app bundle and published it under the closed track flutter build appbundle --flavor prod --release. I also let google sign my app "Google signing the app" when I was uploading the artifact.

  2. I've added a tester that is not associated with the developer account and added the same email under "License testing" with the License response "RESPOND_NORMALLY".

  3. I've also created three consumable products and set them to active.

The following shows my code that fetches products

  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());

The following shows the unexpected results I'm getting. That is all of my products are in the notFoundIDs list. [my_app_premium_year_c, my_app_premium_month_c, my_app_premium_week_c]

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

Any hints or suggestions would be much appreciated.

EDIT: The following screenshot shows my in-app products page on the google console. I've covered up certain identifiers to protect my privacy, however the product ids in the screenshot match the product ids in my code.
in-app-products

The following screenshot shows my app published under the alpha, closed track.
alpha track

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩人痒 2025-01-24 16:27:20

问题终于解决了。在Android平台上,您需要在queryProductDetails()之前调用InAppPurchase方法isAvailable()。我不知道为什么在 IOS 平台上不需要做同样的事情。

该文档没有明确说明是否需要这样做,但可以肯定的是,在检查商店是否可用后查询产品可以解决我在 Android 上的问题。

The issue has finally been solved. You need to call InAppPurchase method, isAvailable(), before queryProductDetails() when on the Android platform. I'm not sure why you don't need to do the same when on the IOS platform.

The documentation didn't specify the need for this outright, but let it stand that querying for products AFTER checking if the store is available fixed my issue on Android.

秉烛思 2025-01-24 16:27:20

该问题已解决,因为我有两个独立的环境:开发 (dev) 和生产 (prod)。开发环境的包名称是 com.company.app.dev,而生产环境的包名称是 com.company.app。由于 Play 商店配置了包 ID com.company.app,因此开发环境无法获取产品,因为包名称与 Play 商店中注册的包名称不匹配。

The issue was resolved because I had two separate environments: development (dev) and production (prod). The package name for the dev environment was com.company.app.dev, while for the prod environment, it was com.company.app. Since the Play Store was configured with the package ID com.company.app, the dev environment couldn't fetch the products, as the package name didn't match the one registered in the Play Store.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文