16

我正在学习应用内计费,但​​我对谷歌的应用内计费示例(地下城之一)有疑问。

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

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

接下来我将签名的应用程序安装到我的手机上,但是当我尝试购买剑或药水时,我得到了一个项目不可用的错误

您请求的项目无法购买。

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

我错过了什么?

4

9 回答 9

38

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

于 2015-09-08T11:27:08.867 回答
25

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.

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.

于 2012-08-05T16:09:16.787 回答
13

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

于 2015-09-18T04:40:39.503 回答
7

我对这个错误的经验是:

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

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

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

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

  5. 确保在您的开发者控制台中创建应用计费,最后从控制台激活该项目!!!(这是在完全遵循谷歌教程后得到我的那个)

于 2013-08-11T13:07:50.733 回答
2

仅上传未发布的草稿 apk 来测试应用内计费已不再足够。您需要做的是将 apk 上传到开发者控制台上的 alpha 或 beta apk 部分。然后,您需要发布它。如果您在 Production APK 部分中还有一个草稿 apk,请务必在发布之前将其删除。否则它将提供给所有人。

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

这是谷歌的文档:

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

于 2014-07-12T16:48:29.857 回答
1

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

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

于 2012-08-21T11:41:24.233 回答
1

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

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

于 2012-06-13T18:51:09.873 回答
1

发布应用程序对我有用(并让它发布(!))。我不得不等待谷歌也更新他们的数据库,正如其他地方所提到的,谷歌播放的变化不是立即的。

于 2012-08-15T00:40:15.107 回答
1

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

3:)

于 2016-02-26T11:20:34.600 回答