我正在尝试使用自己的sku /产品ID“upgrade_to_premium”来测试应用内结算。正如我在这里看到的推荐,我正在使用Dungeons示例应用程序。我已将“new CatalogEntry(”upgrade_to_premium“,R.string.upgrade_to_premium,Managed.MANAGED)”添加到Dungeons.java中的CatalogEntry []数组中。在Const.java中,DEBUG设置为TRUE。
我已将发布已签名的.apk上传到我的开发者控制台并将其激活,并使用adb将此相同的.apk安装到我的设备上。
我在开发者控制台中输入了同名的应用内商品,并将其发布。
我登录的手机不是使用我的开发者帐户,而是使用我的开发者控制台注册的测试Google帐户。此帐户具有相关的信用卡信息;我可以用它买音乐。
我的设备正在运行Gingerbread,并进行了最新的Google Play升级。
在手机上启动新安装的应用程序后,我在LogCat中观察到预期的RestoreTransactions调用,但它返回RESULT_DEVELOPER_ERROR。 (不是一个好的开始?我想不是,但是这个错误的五个不同的记录的可能的原因在这里不适用,谁知道有多少没有文档。)然后我尝试购买我的自定义sku upgrade_to_premium,但我得到了一个标题为“错误”的警告对话框,其中包含“未找到项目”消息,连续两次,几乎是通常显示带有VISA信息的市场(播放)用户界面的时间。有趣的是,我在尝试包含无效(即未发布)包名称的市场URL时发现了类似的错误。我上传的未发布的草稿是未找到的吗?我的自定义sku没有找到?从模糊的错误消息中很难说清楚。有人有任何线索吗?感谢。
这是LogCat输出:
06-13 00:08:31.858: D/Finsky(589): [1] 5.onFinished: Installation state replication succeeded.
06-13 00:08:43.729: I/ActivityManager(109): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.augmentedmind.dungeons/.Dungeons } from pid 196
6-13 00:08:43.795: I/ActivityManager(109): Start proc com.augmentedmind.dungeons for activity com.augmentedmind.dungeons/.Dungeons: pid=1247 uid=10054 gids={}
06-13 00:08:44.198: D/BillingService(1247): CheckBillingSupported
06-13 00:08:44.198: I/BillingService(1247): binding to Market billing service
06-13 00:08:44.213: D/BillingService(1247): CheckBillingSupported
06-13 00:08:44.213: I/BillingService(1247): binding to Market billing service
06-13 00:08:44.221: D/BillingService(1247): Billing service connected
06-13 00:08:44.225: D/BillingService(1247): CheckBillingSupported
06-13 00:08:44.237: D/Finsky(589): [26] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:08:44.241: I/BillingService(1247): CheckBillingSupported response code: RESULT_OK
06-13 00:08:44.241: I/Dungeons(1247): supported: true
06-13 00:08:44.241: D/BillingService(1247): RestoreTransactions
06-13 00:08:44.245: D/Finsky(589): [8] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:08:44.249: D/Finsky(589): [8] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:08:44.260: I/ElegantRequestDirector(589): I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
06-13 00:08:44.260: E/BillingService(1247): restoreTransactions received RESULT_OK
06-13 00:08:44.260: D/BillingService(1247): request id: 2247584787757221561
06-13 00:08:44.260: I/ElegantRequestDirector(589): Retrying request
06-13 00:08:44.268: D/BillingService(1247): request id: -1
06-13 00:08:44.268: D/BillingService(1247): CheckBillingSupported
06-13 00:08:44.272: D/Finsky(589): [7] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:08:44.272: I/BillingService(1247): CheckBillingSupported response code: RESULT_OK
06-13 00:08:44.272: I/Dungeons(1247): supported: true
06-13 00:08:44.272: D/BillingService(1247): request id: -1
06-13 00:08:44.346: I/ActivityManager(109): Displayed com.augmentedmind.dungeons/.Dungeons: +556ms
06-13 00:08:44.729: D/Finsky(589): [1] MarketBillingService.sendResponseCode: Sending response RESULT_DEVELOPER_ERROR for request 2247584787757221561 to com.augmentedmind.dungeons.
06-13 00:08:44.741: I/BillingService(1247): handleCommand() action: com.android.vending.billing.RESPONSE_CODE
06-13 00:08:44.741: D/BillingService(1247): RestoreTransactions: RESULT_DEVELOPER_ERROR
06-13 00:08:44.741: D/Dungeons(1247): RestoreTransactions error: RESULT_DEVELOPER_ERROR
06-13 00:09:28.049: D/Dungeons(1247): buying: Upgrade app to premium sku: upgrade_to_premium
06-13 00:09:28.053: D/BillingService(1247): RequestPurchase
06-13 00:09:28.092: D/Finsky(589): [26] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:09:28.096: D/Finsky(589): [26] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:09:28.100: I/ActivityManager(109): Starting: Intent { act=android.intent.action.VIEW cmp=com.android.vending/com.google.android.finsky.activities.IabActivity (has extras) } from pid -1
06-13 00:09:28.104: D/BillingService(1247): request id: 137676918944123250
06-13 00:09:28.104: D/BillingService(1247): RequestPurchase
06-13 00:09:28.108: D/Finsky(589): [27] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:09:28.112: D/Finsky(589): [27] MarketBillingService.getPreferredAccount: com.augmentedmind.dungeons: Account from first account.
06-13 00:09:28.112: I/ActivityManager(109): Starting: Intent { act=android.intent.action.VIEW cmp=com.android.vending/com.google.android.finsky.activities.IabActivity (has extras) } from pid -1
06-13 00:09:28.116: D/BillingService(1247): request id: 5138873787070031749
06-13 00:09:28.174: D/Finsky(589): [1] SelfUpdateScheduler.checkForSelfUpdate: Skipping self-update. Local Version [8011019] >= Server Version [0]
06-13 00:09:28.381: I/ActivityManager(109): Displayed com.android.vending/com.google.android.finsky.activities.IabActivity: +262ms
06-13 00:09:28.413: E/Volley(589): [13] BasicNetwork.performRequest: Unexpected response code 500 for https://android.clients.google.com/fdfe/details?doc=subs:com.augmentedmind.dungeons:upgrade_to_premium
06-13 00:09:41.670: W/InputManagerService(109): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40796830
06-13 00:09:41.737: D/Finsky(589): [1] SelfUpdateScheduler.checkForSelfUpdate: Skipping self-update. Local Version [8011019] >= Server Version [0]
大约在这个时间我在设备屏幕上出现一个名为“Error”的弹出对话框,其中显示消息“Item not found”,两次。几乎就是通常会显示带有VISA信息的市场(Play)用户界面的时间。
06-13 00:09:41.881: D/Finsky(589): [1] MarketBillingService.sendResponseCode: Sending response RESULT_ERROR for request 5138873787070031749 to com.augmentedmind.dungeons.
06-13 00:09:41.889: I/BillingService(1247): handleCommand() action: com.android.vending.billing.RESPONSE_CODE
06-13 00:09:41.889: D/BillingService(1247): RequestPurchase: RESULT_ERROR
06-13 00:09:41.893: D/Finsky(589): [1] PendingNotificationsService.setMarketAlarm: Setting alarm for account=tester.android30@gmail.com, duration=120000
06-13 00:09:41.940: I/ActivityManager(109): Displayed com.android.vending/com.google.android.finsky.activities.IabActivity: +271ms
06-13 00:09:41.991: E/Volley(589): [14] BasicNetwork.performRequest: Unexpected response code 500 for https://android.clients.google.com/fdfe/details?doc=inapp:com.augmentedmind.dungeons:upgrade_to_premium
06-13 00:09:45.600: W/InputManagerService(109): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@407daea0
06-13 00:09:45.682: D/Finsky(589): [1] MarketBillingService.sendResponseCode: Sending response RESULT_ERROR for request 137676918944123250 to com.augmentedmind.dungeons.
06-13 00:09:45.690: D/Finsky(589): [1] PendingNotificationsService.setMarketAlarm: Setting alarm for account=tester.android30@gmail.com, duration=120000
06-13 00:09:45.698: I/BillingService(1247): handleCommand() action: com.android.vending.billing.RESPONSE_CODE
06-13 00:09:45.698: D/BillingService(1247): RequestPurchase: RESULT_ERROR
06-13 00:09:45.698: D/Dungeons(1247): upgrade_to_premium: RESULT_ERROR
06-13 00:09:45.698: I/Dungeons(1247): purchase failed
P.S。我读到某个地方“可能需要等待一个小时才能激活它”但我真诚地希望未发布的草稿上传不是这样的!为什么这种上传,没有用户会看到,会受到延迟? ...我开始认为这是真的,因为通过重复上传/删除/重新上传此未发布的草稿应用我刚刚达到上传配额。尽管掌握了应用内结算的痛苦,但我并不需要额外的烦恼。不好,谷歌。
答案 0 :(得分:9)
您必须发布产品(而不是应用程序)才能使用此功能。是的,你需要等一下。据推测,当您的APK状态被复制到所有Google Play服务器时。它曾经在大约一年前马上工作,但事实并非如此。但是,您不需要上传和测试相同的APK ,只需要匹配版本和签名。因此,当您开始开发新版本时,只需在清单中修改版本,导出并上传已签名的APK。在你开发和测试时让它坐在那里。然后在发布时将其替换为最终二进制文件。
答案 1 :(得分:0)
在Security类的变量base64EncodedPublicKey
中设置您的公钥。
并使用signed apk在应用结算中进行测试。
答案 2 :(得分:0)
你应该注意到Dungeons.java演示中有一些非常误导的错误和对话框:
-
如果您收到“错误:此版本的应用程序未配置为市场结算。”
您必须将 RELEASE apk安装到您的android DEVICE 而不是模拟器中:
导出APK并签名
在您的设备上删除以前安装的应用程序(甚至是调试版/开发人员版本!)
将APK加载到您的设备,安装并运行它。
这也意味着调试已发布的应用程序可能没有连接调试器。如果您的调试器已附加,请告诉我如何!
如果你收到“错误:找不到物品”,那么就有可能没有错。
Dungeons.java实际上有一个错误。让我解释一下:
/**
* Called when a button is pressed.
*/
@Override
public void onClick(View v) {
if (v == mBuyButton) {
if (Consts.DEBUG) {
Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
}
if (mManagedType != Managed.SUBSCRIPTION &&
// ** The following line is bug when returns !true which is false, and then makes the if statement false
!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
// ** Which then ends up running this else if, meaning it will try to purchase a subscription
} else if (!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_SUBSCRIPTION, mPayloadContents)) {
// Note: mManagedType == Managed.SUBSCRIPTION
showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
}
} else if (v == mEditPayloadButton) {
showPayloadEditDialog();
} else if (v == mEditSubscriptionsButton) {
editSubscriptions();
}
}
相反它应该写成这样:
/**
* Called when a button is pressed.
*/
@Override
public void onClick(View v) {
if (v == mBuyButton) {
if (Consts.DEBUG) {
Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
}
// We need this statement to evaluate to true on a Non-Subscription such as a Managed or Unmanaged Purchase
if (mManagedType != Managed.SUBSCRIPTION) {
// If the following errors out, show an error dialog. However, it should not make the previous if statement false
if( !mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
}
}
// This if statement gets run accidentally without the bug fix, thus trying to buy your "SKU" as a "subscription", which is totally wrong!
else if (!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_SUBSCRIPTION, mPayloadContents)) {
// Note: mManagedType == Managed.SUBSCRIPTION
showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
}
} else if (v == mEditPayloadButton) {
showPayloadEditDialog();
} else if (v == mEditSubscriptionsButton) {
editSubscriptions();
}
}
答案 3 :(得分:0)
试试这个:
将您的应用导出为APK文件。 将APK上传到Google Play。 将相同的APK加载到您的测试设备。 等待一个小时左右的时间让Google Play更新其服务器。 测试已安装的APK。