2

我正在尝试使用我自己的 sku/产品 ID“upgrade_to_premium”测试应用内计费。正如我在这里看到的推荐,我使用的是地下城示例应用程序。我在 Dungeons.java 的 CatalogEntry[] 数组中添加了一个“new CatalogEntry("upgrade_to_premium", R.string.upgrade_to_premium, Managed.MANAGED)”。在 Const.java 中,DEBUG 设置为 TRUE。

我已将发布签名的 .apk 上传到我的开发者控制台并激活它,并使用 adb 将相同的 .apk 安装到我的设备上。

我在开发控制台中输入了一个同名的应用内产品,并发布了它。

我不是使用我的开发者帐户登录我的手机,而是使用在我的开发者控制台注册的测试 Google 帐户。此帐户有关联的信用卡信息;我可以用它购买音乐。

我的设备正在运行 Gingerbread,并带有最新的 Google Play 升级。

在我的手机上启动新安装的应用程序后,我在 LogCat 中观察到预期的 RestoreTransactions 调用,但它返回 RESULT_DEVELOPER_ERROR。(不是一个好的开始?我想不是,但是记录了五个不同的此错误的可能原因不适用于此处,谁知道有多少未记录的。)然后我尝试购买我的自定义 sku upgrade_to_premium,但我收到一个标题为“错误”的警报对话框,并显示消息“未找到项目”,两次接连,就在它通常会显示带有 VISA 信息的市场(播放)UI 的时间。有趣的是,在尝试包含无效(即未发布)包名称的市场 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]

大约在这个时候,我在设备屏幕上弹出一个对话框,标题为“错误”,并显示消息“未找到项目”,两次。就在它通常会显示带有 VISA 信息的市场 (Play) UI 的时候。

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

PS 我在某处读到“可能需要等待一个小时左右才能激活它”,但我真诚地希望未发布的草稿上传不是这种情况!为什么这种用户永远看不到的上传会受到延迟?...我开始认为这是真的,因为通过重复上传/删除/重新上传这个未发布的草稿应用程序,我刚刚达到了上传配额。就像掌握应用内计费一样痛苦,我不需要那种额外的烦恼。不好,谷歌。

4

4 回答 4

10

您必须发布产品(而不是应用程序)才能使其正常工作。是的,您需要稍等片刻。大概是当您的 APK 状态被复制到所有 Google Play 服务器时。大约一年前它曾经可以立即工作,但现在不再是这种情况了。但是,您不需要上传和测试同一个 APK,只需要版本和签名匹配。因此,当您开始开发新版本时,只需在清单中添加版本,导出并上传签名的 APK。在您开发和测试时让它坐在那里。然后在发布时将其替换为您的最终二进制文件。

于 2012-06-13T08:17:31.793 回答
0

base64EncodedPublicKey在 Security 类的变量中设置您的公钥。

并使用签名的 apk 在应用计费中进行测试。

于 2012-06-13T08:17:24.760 回答
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();
    }
}
于 2012-11-29T20:45:29.337 回答
0

试试这个:

将您的应用导出为 APK 文件。将 APK 上传到 Google Play。将相同的 APK 侧载到您的测试设备。等待一个小时左右,让 Google Play 更新其服务器。测试已安装的 APK。

于 2014-09-12T10:26:21.237 回答