Closed just4phil closed 6 years ago
gdxAppObject should not be null. However, it will be null as long as libGDX is not initialized yet as "Gdx.app" is null. Are you calling PurchaseSystem... after you fully initialized libGDX?
ok i tried this:
i still get a nullpointer:
11-25 21:36:32.891: E/ACRA(12316): de.philweb.bubblr2 fatal error : null
11-25 21:36:32.891: E/ACRA(12316): java.lang.NullPointerException
11-25 21:36:32.891: E/ACRA(12316): at com.badlogic.gdx.pay.android.openiab.PurchaseManagerAndroidOpenIAB.purchaseRestore(PurchaseManagerAndroidOpenIAB.java:323)
11-25 21:36:32.891: E/ACRA(12316): at com.badlogic.gdx.pay.PurchaseSystem.purchaseRestore(PurchaseSystem.java:188)
11-25 21:36:32.891: E/ACRA(12316): at de.philweb.bubblr2HD.tools.PlatformResolver.requestPurchaseRestore(PlatformResolver.java:40)
11-25 21:36:32.891: E/ACRA(12316): at de.philweb.bubblr2HD.screens.LoadingAsyncScreen.
That's odd. From the error message it seems the purchase manager was set within purchase system but the variable "helper" in OpenIAB appears null. Either (a) install hasn't finished/wasn't called yet or (b) dispose() was called before you call purchase restore.
hi @noblemaster !!
my game tankWar is actually available on the amazon fire tv box and performs good. i see some crash reports in the dev-console. the crashs occur in: PurchaseManagerAndroidOpenIAB.java:323
thats odd because i manually wire up my own amazon-IAP-manager. i use a global final static for it: public static final int ISAPPSTORE = Game.APPSTORE_AMAZON;
the androidLauncher wires up the platformResolver:
if(Tanks.ISAPPSTORE == Game.APPSTORE_OUYA) {
Game.setPlatformResolver(new OUYAResolver(tanks, this));
}
else if(Tanks.ISAPPSTORE == Game.APPSTORE_GOOGLE) { // we are on android (no ouya)
Game.setPlatformResolver(new AndroidResolver(tanks, this));
}
else if(Tanks.ISAPPSTORE == Game.APPSTORE_AMAZON) {
Game.setPlatformResolver(new AmazonFireResolver(tanks, this));
}
and the resolver wires up the IAP manager:
PurchaseManagerAndroidAmazon mgr = new PurchaseManagerAndroidAmazon(androidApplication, 1001);
PurchaseManagerConfig config = tanks.purchaseManagerConfig;
initializeIAP(mgr, tanks.purchaseObserver, config);
this works well (i know it because i already have 47 purchases from different countries) so why/how can it be that i get crashes from PurchaseManagerAndroidOpenIAB???
i still believe that the reflection code is causing those problems!? what do you think? any suggestions?
bye phil
Hard to tell with any error logs. If you resolve the platform yourself, the reflection code isn't called and shouldn't pose any problems. Did you link in the activity listener where needed as well?
Given you have 47 purchases already, the error might be related some older/outdated OS versions? Or a rooted phone? Maybe some temporary internet problem on those devices?
hi @noblemaster there must be a case where somehow the reflection code gets called because the amazon IAP mgr isnt in place...
my code checks if there is a manager. in that case it just sets the manager in the purchase system. if mgr == null the normal reflection code would be called.
maybe the amazon IAP manager gets lost during pause/resume? or openIAB gets bound after the amazonIAP mgr has been disposed (that happens after the purchase of the full version)??
i am confused!!
what do you mean by: "Did you link in the activity listener where needed as well?" => what do i have to do here?
and how could a rooted phone cause the problems?
bye phil
What you explain sounds fine to me. Without any logs or more details it's however very difficult to guess what goes wrong?
@noblemaster here is the stacktrace (see below)
the app starts with the correct amazon iap purchase manager but somehow it gets lost (maybe after pause/resume?... lost statics??) and then the reflection code seems to set the openIAB manager(?) in purchaseRestore() via PurchaseSystem.hasManager()
i only dispose the manager after a purchase and in onDestroy() .... i dont do anything in pause/resume.
i see only 7 crashes in purchase() but i see 312 crashes in purchaseRestore()
this sucks and confuses me :)
java.lang.NullPointerException at com.badlogic.gdx.pay.android.openiab.PurchaseManagerAndroidOpenIAB.purchaseRestore(PurchaseManagerAndroidOpenIAB.java:323) at com.badlogic.gdx.pay.PurchaseSystem.purchaseRestore(PurchaseSystem.java:188) at de.philweb.philengine.common.PlatformResolver.requestPurchaseRestore(PlatformResolver.java:42) at de.philweb.game2.screens.LoadingAsyncScreen.(LoadingAsyncScreen.java:112) at de.philweb.game2.common.Tanks.getStartScreen(Tanks.java:174) at de.philweb.philengine.common.Game.create(Game.java:277) at de.philweb.game2.common.Tanks.create(Tanks.java:133) at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:237) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
Looks like the helper is null!? The system is either not initialized (yet) or already disposed. Did you put some log messages in to check if the helper is instantiated etc.?
well .... PurchaseManagerAndroidOpenIAB should never be called because its the amazon platform!!
@noblemaster hi chris! i still have a serious problem (with the reflection stuff?) i still get crash reports from my amazon fire tv app, where NO(!!!) openIAB purch.mgr. should be used! i get a nullpointer in your new refreshSKUs(): java.lang.NullPointerException PurchaseManagerAndroidOpenIAB.java:159 for (int i = 0; i < config.getOfferCount(); i++) {
what makes me nervous is that there shouldnt be a PurchaseManagerAndroidOpenIAB!!!!! the fire tv app can only bind PurchaseManagerAndroidAmazon!! so why is there sometimes the PurchaseManagerAndroidOpenIAB bound??
this means that some people cant buy my app and thats a bad thing ;) bye phil
I checked your code & found the following: https://github.com/libgdx/gdx-pay/blob/master/gdx-pay-android-amazon/src/com/badlogic/gdx/pay/android/amazon/PurchaseManagerAndroidAmazon.java#L213
Don't call PurchaseSystem in your custom Amazon purchase manager. That code will instantiate the OpenIAB purchase manager via reflection...
thx!! i saw that too and asked myself where this is used... i will change that thanks!!!!
@noblemaster hast du google hangouts?
@noblemaster Just received the next crash report about openIAB mgr in my amazon fire TV game....from the New Version where i disabled the Call to hasManager()
That sucks!
What am i doing wrong??
I dont like the automatic reflection stuff! The user should have full control over what is happening! How can i fully disable the reflection stuff?? We should at least offer a method to disable it and let the user control it manually without those side effects...
You probably have some other places where you use "PurchaseSystem". Given that you don't use reflection, do a search in your code for "PurchaseSystem" and removed it. Also, Search for "IAP" which does reflection for the Android backend. Please make sure to add the onActivityResult listener though.
A cleaner option would be to update IAP.java and add reflection code for Amazon Fire TV; i.e. if you are on Amazon Fire TV, make it to use your custom Amazon backend and prevent instantiation of OpenIAB.
Sorry, hardly using Google Hangouts at all!
I think this can be closed. We have #128 on how to use on Amazon devices and #159 for discussing if PurchaseSystem should be used anymore.
Thanks for your input!
Hi @noblemaster if i use gdx-pay regularly on my amazon fire tv i always get a purchasemanager == null. after investigation i found out:
gdxClazz = com.badlogic.gdx.Gdx gdxLifecycleListenerClazz = com.badlogic.gdx.LifecycleListener gdxAppObject = null !!! => Object gdxAppObject = gdxClazz.getField("app").get(null); gdxAppLogMethod => fails because gdxAppObject == null => catch error
with deactivated purchasesystem all is running fine!
what can be the problem? bye phil