GdxPay“ onPurchaseHistoryResponse失败,带有responseCode -1”

时间:2018-09-01 11:32:05

标签: android libgdx gdx-pay

这是我在AndroidLauncher onCreate方法(使用libgdx 1.9.6和gdxpay 0.11.3)中设置购买管理器的方式:

purchaseManager = new PurchaseManagerGoogleBilling(this);
PurchaseManagerConfig pmc = new PurchaseManagerConfig();
pmc.addStoreParam(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE, base64EncodedPublicKey);
pmc.addOffer(new Offer().setType(OfferType.ENTITLEMENT).setIdentifier(globals.skuFullVer));

myPurchaseObserver = new MyPurchaseObserver(globals, highScores);
purchaseManager.install(myPurchaseObserver, pmc, true);

purchaseManager.purchaseRestore();  

但是,当调用purchaseRestore()时,出现以下异常:

FATAL EXCEPTION: main
Process: com.eb.droid, PID: 8823
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eb.droid/com.eb.droid.android.AndroidLauncher}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.badlogic.gdx.Application.error(java.lang.String, java.lang.String)' on a null object reference
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2491)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2564)
  at android.app.ActivityThread.access$800(ActivityThread.java:170)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1441)
  at android.os.Handler.dispatchMessage(Handler.java:111)
  at android.os.Looper.loop(Looper.java:194)
  at android.app.ActivityThread.main(ActivityThread.java:5576)
  at java.lang.reflect.Method.invoke(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.badlogic.gdx.Application.error(java.lang.String, java.lang.String)' on a null object reference
  at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling$4.onPurchaseHistoryResponse(PurchaseManagerGoogleBilling.java:197)
  at com.android.billingclient.api.BillingClientImpl.queryPurchaseHistoryAsync(BillingClientImpl.java:477)
  at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling.purchaseRestore(PurchaseManagerGoogleBilling.java:191)
  at com.eb.droid.android.AndroidLauncher.onCreate(AndroidLauncher.java:141)
  at android.app.Activity.performCreate(Activity.java:6041)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2564) 
  at android.app.ActivityThread.access$800(ActivityThread.java:170) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1441) 
  at android.os.Handler.dispatchMessage(Handler.java:111) 
  at android.os.Looper.loop(Looper.java:194) 
  at android.app.ActivityThread.main(ActivityThread.java:5576) 
  at java.lang.reflect.Method.invoke(Native Method) 
  at java.lang.reflect.Method.invoke(Method.java:372) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751) 

当我调试PurchaseManagerGoogleBilling.java PurchaseRestore方法时,responseCode返回-1,并且购买对象为null,并且通过Gdx报告以下错误:

onPurchaseHistoryResponse failed with responseCode -1  

请注意,在我设置PurchaseManager之后,我在AndroidLauncher中调用initi> onCreate。

任何人都对这里出了什么问题有任何指示?我已经用旧的IabHelper完成了付款,但是我改用了GdxPay,因为它使用的是更新的BillingLibrary,它应该更稳定。另外,我只针对Android。

1 个答案:

答案 0 :(得分:1)