简体   繁体   English

应用内结算 - 无法购买请求的项目

[英]In-app Billing - Item requested not available for purchase

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 有疑问。

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.我已经导出并签署了应用程序并将其上传到 Google Play 并将其保存为带有几张图片的草稿并激活了 apk。 I also added both the sword_001 and potion_001 as published in-app purchases!我还添加了 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?我错过了什么?

Check your versionCode .检查您的versionCode It can't be higher than the last published/unpublished version in any of your distribution channels (prod/beta/alpha).它不能高于您的任何分发渠道(产品/测试版/阿尔法)中最后发布/未发布的版本。

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.我的代码价值很大程度上基于 Google Android 演示,但我去除了很多复杂性。 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.我首先获得了静态测试产品 ID。
  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.应用程序必须在上传之前以通常的方式签名(我通过从 Eclipse 导出),但不是那么明显的是,您加载到移动设备的应用程序也必须以相同的方式签名 - 即(调试由 Eclipse 加载到设备的已签名)版本 - 运行或调试 - 将无法正常工作。
  6. They also both need the same version number, I think.我认为它们也需要相同的版本号。 Not 100% sure.不是 100% 确定。 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.将应用上传到 Google 后,可能需要几个小时才能使用它,并且您会收到应用内结算的所有正确响应。 I find 1-2 hours typically.我发现通常 1-2 小时。
  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.我怀疑关于这个主题的其他评论关于你是使用 gmail 还是 googlemail 测试帐户可能是红鲱鱼,但就其价值而言,我的测试帐户是 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.但我确实发现一个人可以在手机上拥有多个谷歌帐户,然后选择一个供 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.我不得不说这是一个相当复杂的系统,没有多少答案,我几乎放弃了。

If your app are on closed alpha testing, you have to sign in with your test account to Opt-in URL;如果您的应用正在进行封闭式 Alpha 测试,您必须使用您的测试帐户登录到 Opt-in URL; https://play.google.com/apps/testing/{your.app.namespace}

My experience on this error is:我对这个错误的经验是:

  1. Make sure to upload the signed APK to developer console.确保将签名的 APK 上传到开发者控制台。

  2. Make sure to install the signed APK on your device not launch the app in the debugger.确保在您的设备上安装已签名的 APK,而不是在调试器中启动应用程序。

  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!!!确保在您的开发者控制台中创建 in app billing 并最终从控制台激活该项目!!! (this is the one that got me after fully following google's tutorial) (这是在完全遵循谷歌的教程后让我得到的)

It's no longer sufficient to just upload an unpublished draft apk to test in-app billing.仅仅上传一个未发布的草稿 apk 来测试应用内计费是不够的。 What you need to do is upload an apk to the alpha or beta apk section on the Developer Console.您需要做的是将 apk 上传到开发人员控制台上的 alpha 或 beta apk 部分。 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.如果您在 Production APK 部分也有草稿 apk,请务必在发布前将其删除。 Otherwise it will be available to everyone.否则它将对每个人都可用。

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

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 Tutorial to 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.如果没有别的,这可能有助于某人查看测试应用内计费示例之一所需的所有步骤。

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 上的变化不会立即发生。

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 并重新设置

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:)

Check if your device have more than one account then remove other accounts and keep the account you have entered in play console then it will be solved.检查您的设备是否有多个帐户然后删除其他帐户并保留您在游戏机中输入的帐户然后它就会解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM