Android计费 - 我收到响应代码5



我的应用程序内计费工作,但后来我移动了一些代码以获得更大的可扩展性,并且破裂了。从本质上讲,我要做的是为我的插件制作一个适配器,以便以后更容易添加它们。我的项目在清单中具有计费权限,并配置为在Google Play商店上进行计费,因此这不是问题。

不符合性

public class AdOnsActivity extends AppCompatActivity {
    private IInAppBillingService mService;
    private ServiceConnection mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mService = null;
        }
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            mService = IInAppBillingService.Stub.asInterface(service);
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ad_ons);
        Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        serviceIntent.setPackage("com.android.vending");
        bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
        listAdOns = findViewById(R.id.listAdOns);
        Handler handler = new Handler();
        handler.post(new Runnable() {
            @Override
            public void run() {
                try {
                    ...
                    listAdOns.setAdapter(new AdOnAdapter(AdOnsActivity.this, json.getJSONArray("adOns"), mService));
                } catch (Exception e) {
                    Toast.makeText(AdOnsActivity.this, getResources().getString(R.string.error_load_ad_ons), Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                    finish();
                }
            }
        });
    }

adonadapter

public class AdOnAdapter extends BaseAdapter {
    public AdOnAdapter(Activity activity, JSONArray adOns, IInAppBillingService mService) throws RemoteException {
        Bundle querySkus = new Bundle();
        this.activity = activity;
        this.adOns = adOns;
        this.mService = mService;
        skuDetails = mService.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
        responseDetails = skuDetails.getInt("RESPONSE_CODE");
        ownedItems = mService.getPurchases(3, activity.getPackageName(), "inapp", null);
        responseOwned = ownedItems.getInt("RESPONSE_CODE");
    }

所有响应代码均在此处列出。

5表示您正在使用无效的参数调用API。您已经以某种方式打破了API电话。也许在代码的旧版本和新版本下比较API调用的内容(您使用的源控件正确吗?(

  • 0。 billing_response_result_ok:成功
  • 1。 billing_response_result_user_canceled:用户向后按或取消对话框
  • 2。 billing_response_result_service_unavailable:网络连接下降
  • 3。 billing_response_result_billing_unavailable:billing api版本不支持所请求的类型
  • 4。 Billing_response_result_item_unavailable:不可用于购买的产品
  • 5。 billing_response_result_developer_error:提供给API的无效参数。此错误还可以表明该应用程序未正确签署或正确设置用于Google Play中的应用内计费,或者在其清单中没有必要的权限
  • 6。 billing_response_result_error:API操作期间的致命错误
  • 7。 Billing_Response_Result_Item_aldready_owned:由于项目已经拥有
  • ,因此未能购买
  • 8。 billing_response_result_item_not_owned:由于项目不拥有
  • 而无法消费

根据文档,此错误可能是一堆事情。对我来说,这是获得许可的用户。当我添加它们时,没有迹象表明将电子邮件添加到许可测试人员列表中。我不断添加它们,对"许可证响应"进行了混乱。保存,但根本没有改变。

一段时间后,我意识到我必须按" Enter"。在电子邮件列表中实际添加用户。我知道这听起来很愚蠢,但这是我唯一的问题(至少我认为这是因为我花了一天的时间寻找原因(。

因此,如果您遇到此错误并且在Settings -> License Testing -> License testers中没有看到任何电子邮件,则可能是使调试正常工作的距离的单个键。

;响应代码5如果没有混淆帐户ID,则无法设置混淆的配置文件ID。这是我的错误。检查后,我发现我的setObfuscatedAccountId是空的。也可能是您提供给帐单客户端的任何其他参数。

最新更新