Android 应用内结算 - 请求的项目不可购买

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11020587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:45:08  来源:igfitidea点击:

In-app Billing - Item requested not available for purchase

androidin-app-purchasein-app-billing

提问by Gatekeeper

I am working on learning in-app billing but I am having a problem with the google's in-app billing example, the Dungeon one.

我正在学习应用内计费,但​​我对谷歌的应用内计费示例 Dungeon one 有疑问。

I have already set up the application, added my public key, and changed the API_VERSION to 1 in the makeRequestBundle().

我已经设置了应用程序,添加了我的公钥,并将 makeRequestBundle() 中的 API_VERSION 更改为 1。

I have already exported and signed the application and uploaded it onto Google Play and saved it as a draft with a few pictures and activated the apk. I also added both the sword_001 and potion_001 as published in-app purchases!

我已经导出并签署了应用程序并将其上传到 Google Play 并将其保存为带有几张图片的草稿并激活了 apk。我还添加了 Sword_001 和 potion_001 作为已发布的应用内购买!

Next I installed the signed app onto my phone but when I try to purchase either the sword or the potion I get an Item unavailable error

接下来,我将签名的应用程序安装到我的手机上,但是当我尝试购买剑或药水时,出现“物品不可用”错误

The item you requested is not available for purchase.

您请求的商品无法购买。

I even tried on a different device to make sure it wasn't because developer's can't purchase their own products, and I get the same message on both devices.

我什至在不同的设备上尝试过,以确保这不是因为开发人员无法购买他们自己的产品,并且我在两台设备上都收到了相同的消息。

What have I missed?

我错过了什么?

采纳答案by Gatekeeper

Well I found a solution to my problem. I wasn't able to get Google's in app purchasing example to work but I was able to get this InApp Billing Tutorialto work using the steps I mentioned in my original post.

好吧,我找到了解决我的问题的方法。我无法让 Google 的应用内购买示例发挥作用,但我能够使用我在原始帖子中提到的步骤使这个应用内结算教程起作用。

If nothing else this may be helpful to someone to see all of the steps that need to be done to test one of the in-app billing examples.

如果没有别的,这可能有助于某人查看测试应用内计费示例之一所需的所有步骤。

回答by cesards

Check your versionCode. It can't be higher than the last published/unpublished version in any of your distribution channels (prod/beta/alpha).

检查您的versionCode. 它不能高于您的任何分发渠道(产品/测试版/阿尔法)中最后发布/未发布的版本。

回答by nmw01223

In app billing seems fraught with pitfalls, but this is what I found that affected availability of items for purchase and also suitability of application:

应用内计费似乎充满陷阱,但这是我发现影响购买物品可用性以及应用程序适用性的原因:

  1. My code for what it was worth was strongly based on the Google Android demo, but I stripped out a lot of the complexity. I have a feeling that having got it to work a better result would be produced by writing it all again from scratch.
  2. I got the static test product ids going first.
  3. Despite what the documentation says, it seemed to me that the purchase item(s) must be published, even when using a test account. Mine didn't work when they weren't, anyway, and I waited quite a long time to see if they would start to work as others have suggested - they still didn't.
  4. You (I anyway) can't publish a purchase item without publishing the app, so what I did was upload and publish the app, create the purchase items, publish them (big button at the bottom of the page), then unpublish the app again. This seems to leave the items published.
  5. The app must be signed in the usual way (I did this by exporting from Eclipse) before uploading, but what isn't so obvious is that the app you load to the mobile MUST also be signed in the same way - ie a (debug signed) version loaded to the device by Eclipse - run or debug - isn't going to work.
  6. They also both need the same version number, I think. Not 100% sure. If so that would unfortunately kind of imply that customers with old versions installed can't purchase anything without upgrading.
  7. When the app is uploaded to Google, it can take several hours before it becomes available and you get all the right responses for the in-app billing. I find 1-2 hours typically.
  8. I suspect the other comments on this subject about whether you use a gmail or googlemail test account might be red herrings, but for what it is worth, my test account is gmail.
  9. I did come across a useful little note on the internet somewhere about how to change your primary account on the mobile without having to do a hard reset (and consequently losing everything), but unfortunately I haven't managed to find it again.
  10. What I did find though is that one can have several google accounts on the mobile, and then select the one to be used by Google Play.
  1. 我的代码价值很大程度上基于 Google Android 演示,但我去除了很多复杂性。我有一种感觉,如果让它工作起来,从头开始重新编写它会产生更好的结果。
  2. 我首先获得了静态测试产品 ID。
  3. 尽管文档说了什么,但在我看来,即使使用测试帐户,也必须发布购买项目。无论如何,当它们不工作时,我的也不工作,我等了很长时间,看看它们是否会像其他人建议的那样开始工作 - 他们仍然没有。
  4. 你(我无论如何)不能在不发布应用程序的情况下发布购买项目,所以我所做的是上传和发布应用程序,创建购买项目,发布它们(页面底部的大按钮),然后取消发布应用程序再次。这似乎使项目得以发布。
  5. 应用程序必须在上传之前以通常的方式签名(我通过从 Eclipse 导出),但不是那么明显的是,您加载到移动设备的应用程序也必须以相同的方式签名 - 即(调试已签名)版本由 Eclipse 加载到设备 - 运行或调试 - 将无法工作。
  6. 我认为它们也需要相同的版本号。不是 100% 确定。如果是这样,不幸的是,这意味着安装了旧版本的客户无法在不升级的情况下购买任何东西。
  7. 将应用上传到 Google 后,可能需要几个小时才能使用它,并且您会收到应用内结算的所有正确响应。我发现通常 1-2 小时。
  8. 我怀疑关于这个主题的其他评论关于你是使用 gmail 还是 googlemail 测试帐户可能是红鲱鱼,但就其价值而言,我的测试帐户是 gmail。
  9. 我确实在互联网上的某处看到了一个有用的小笔记,关于如何在移动设备上更改您的主帐户而不必进行硬重置(因此会丢失所有内容),但不幸的是我没有再次找到它。
  10. 但我确实发现可以在移动设备上拥有多个谷歌帐户,然后选择一个供 Google Play 使用的帐户。

Hope this helps somebody. I have to say its a pretty complicated system, with not many switten down answers, and I nearly gave up on it.

希望这可以帮助某人。我不得不说这是一个相当复杂的系统,没有多少答案,我几乎放弃了。

回答by sulaiman sudirman

If your app are on closed alpha testing, you have to sign in with your test account to Opt-in URL; https://play.google.com/apps/testing/{your.app.namespace}

如果您的应用正在进行封闭式 Alpha 测试,您必须使用您的测试帐户登录到 Opt-in URL; https://play.google.com/apps/testing/{your.app.namespace}

回答by pinux

My experience on this error is:

我对这个错误的经验是:

  1. Make sure to upload the signed APK to developer console.

  2. Make sure to install the signed APK on your device not launch the app in the debugger.

  3. Make sure to create a test account in your developer console.

  4. Make sure to sign in your device with your test account.

  5. Make sure to create in app billing in your developer console and finally activate the item from the console!!! (this is the one that got me after fully following google's tutorial)

  1. 确保将签名的 APK 上传到开发者控制台。

  2. 确保在您的设备上安装已签名的 APK,而不是在调试器中启动应用程序。

  3. 确保在您的开发者控制台中创建一个测试帐户。

  4. 确保使用您的测试帐户登录您的设备。

  5. 确保在您的开发者控制台中创建 in app billing 并最终从控制台激活该项目!!!(这是在完全遵循谷歌的教程后让我得到的)

回答by Gino

It's no longer sufficient to just upload an unpublished draft apk to test in-app billing. What you need to do is upload an apk to the alpha or beta apk section on the Developer Console. Then, you need to publish it. If you also have a draft apk in the Production APK section, be sure to delete it before you publish. Otherwise it will be available to everyone.

仅仅上传一个未发布的草稿 apk 来测试应用内计费是不够的。您需要做的是将 apk 上传到开发人员控制台上的 alpha 或 beta apk 部分。然后,您需要发布它。如果您在 Production APK 部分也有草稿 apk,请务必在发布前将其删除。否则它将对每个人都可用。

Publishing an alpha or beta apk makes that apk available to only those testers that you specify/allow.

发布 alpha 或 beta apk 使该 apk 仅可用于您指定/允许的那些测试人员。

Here is Google's documentation on this:

这是谷歌的文档:

https://support.google.com/googleplay/android-developer/answer/6062777?rd=1

https://support.google.com/googleplay/android-developer/answer/6062777?rd=1

回答by Hunter-Orionntheitroad

Anecdotal Supplement:If you have an existing app in the portal already and you want to test a signed version, but not upload it into the portal for distribution. Do the normal steps to build a signed version BUT use your latest version code that is uploaded into the portal. You will will be able to do a quick and dirty test of purchasing (you can't upload this version on the Google Play portal, but it's a means to an end for a localized test (or even as a way to allow side loaded distributed versions/flavors that use Google Play for billing legitimately.)

轶事补充:如果您在门户中已经有一个现有的应用程序,并且您想要测试签名版本,但不想将其上传到门户进行分发。执行正常步骤来构建签名版本,但使用上传到门户的最新版本代码。您将能够对购买进行快速而肮脏的测试(您无法在 Google Play 门户上上传此版本,但它是结束本地化测试的一种手段(或者甚至作为一种允许侧面加载分布式的方式)使用 Google Play 进行合法计费的版本/风格。)

3:)

3:)

回答by AsterLUX

Publishing the app did the trick for me(and leaving it published (!)). I had to wait a bit for Google to update their database as well, as mentioned elsewhere, changes on Google Play are not immediate.

发布应用程序对我有用(并让它发布(!))。我不得不等待 Google 更新他们的数据库,正如其他地方提到的,Google Play 上的变化不会立即发生。

回答by Adam

Also had this problem for a couple of days and searched around a lot. I found this guy who said deleting the app and then reuploading fixed his problem, and that actually worked for me aswell.

也有这个问题几天并搜索了很多。我发现这个人说删除应用程序然后重新上传解决了他的问题,这实际上对我也有用。

Try that, delete your app from the developer console entirely. And reuppload a new signed apk and set it up all over again

尝试一下,从开发者控制台中完全删除您的应用程序。并重新上传一个新签名的 apk 并重新设置