我正在尝试在我的应用程序中实现应用内结算系统,但我无法查询库存以检索订阅,因为我收到以下错误:
IabResult: Error refreshing inventory (querying owned items). (response: -1003:Purchase signature verification failed)
我做了什么:
代码(活动中):
private IabHelper mIabHelper;
// Init setup listener
private IabHelper.OnIabSetupFinishedListener mIabSetupListener = new IabHelper.OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult result) {
if (result.isSuccess()) {
// Load success, now query for inventory
List<String> skus = new ArrayList();
skus.add("packagename.org.dev.subscription.monthly");
skus.add("packagename.org.dev.subscription.yearly");
mIabHelper.queryInventoryAsync(true, skus, mQueryInventoryFinishedListener);
}
}
};
// Listener to load the subscriptions
private IabHelper.QueryInventoryFinishedListener mQueryInventoryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
if (result.isFailure()) {
Log.e(TAG, "Failure, check error!");
return;
}
}
};
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
mIabHelper = new IabHelper(this, PUBLIC_KEY_BASE_64);
mIabHelper.enableDebugLogging(true, "BILLING");
mIabHelper.startSetup(mIabSetupListener);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mIabHelper == null || !mIabHelper.handleActivityResult(requestCode, resultCode, data))
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mIabHelper != null) {
mIabHelper.dispose();
}
}
我在设备上复制了相同的APK(已签名)并安装了它,但我收到了上述错误。我也在调试模式下运行应用程序,同样的错误。我不知道该怎么做。
我在这里看到(stackoverflow)Google API正在缓存一些数据。我应该重置工厂吗?或者我如何清除缓存的数据?
答案 0 :(得分:0)
如果您的应用的基本64公钥不正确,签名验证将失败。确保使用正确的&#34; PUBLIC_KEY_BASE_64&#34;。