我目前正在尝试为应用内购买配置我的应用,但它无法正常工作。每次我尝试启动购买流程时,都会显示“此版本的应用程序未配置为通过Google Play结算”。我很确定我已经完成了必要的步骤以使其发挥作用。我还测试了SKU-Id“android.test.purchased”,它工作正常。
base64EncodedPublicKey
是def。与开发者控制台中的代码
我没有忘记我的清单中的<uses-permission android:name="com.android.vending.BILLING" />
我已将我在测试设备上使用的Google帐户应用为开发者控制台中的测试人员帐户
我在开发者控制台中使用与我的设备完全相同的APK。我通过adb -d install
所以任何想法我可能做错了什么?
这是我的代码: (的onCreate)
base64EncodedPublicKey
iabHelper = new IabHelper(this, base64EncodedPublicKey);
iabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(PURCHASE_TAG, "Problem setting up In-app Billing: " + result);
} else if (result.isSuccess()){
// Hooray, IAB is fully set up!
Log.d(PURCHASE_TAG, "Setup completed: " + result);
iabHelper.queryInventoryAsync(true, null, queryFinishedListener);
}
}
});
(onActivityResult)
if (iabHelper.handleActivityResult(requestCode, resultCode, data)) {
Log.d("TAG", "onActivityResult handled by IABUtil.");
return;
}
(点击按钮开始购买流程)
if(isPremium){
saveImageToGallery(imageState.image);
} else if (iabHelper != null) {
iabHelper.flagEndAsync();
purchaseItem(SKU_TEST);
(购买项目())
private void purchaseItem(String sku) {
iabHelper.launchPurchaseFlow(this, sku, 10001,
purchaseFinishedListener);
}
(监听器)
IabHelper.QueryInventoryFinishedListener
queryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory)
{
if (result.isFailure()) {
// handle error
return;
} else if (result.isSuccess()){
Log.d("$$$$$$$$$$$$$$$", "" + result);
}
}
};
IabHelper.OnIabPurchaseFinishedListener purchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Log.d("ERROR_TAG", "Error purchasing: " + result);
return;
}
else if (purchase.getSku().equals(SKU_TEST)) {
// give user access to premium content and update the UI
isPremium = purchase.getSku().equals(SKU_TEST);
}
}
};
答案 0 :(得分:0)
我认为您应该检查您为apk签名的密钥库。您必须为已上传到Google Play并进行测试的apk使用相同的密钥库。
答案 1 :(得分:0)
我讨厌同样的问题,我修理过:
更多https://developer.android.com/google/play/billing/billing_testing.html
摘要: