Android Question java.lang.NullPointerException when trying to initialize In-App billing

Discussion in 'Android Questions' started by trueboss323, Mar 17, 2015.

  1. trueboss323

    trueboss323 Active Member Licensed User

    Hello all,
    I get this following error when I try to initialize my In-App billing manager.

    Code:
    bmanager.Initialize("bmanager", key)




    java.lang.NullPointerException
    at anywheresoftware.b4a.objects.IbHelper.startSetup(IbHelper.java:269)
    at anywheresoftware.b4a.inappbilling3.BillingManager3.Initialize(BillingManager3.java:44)
    at com.calculator.main._activity_create(main.java:741)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at com.calculator.main.afterFirstLayout(main.java:100)
    at com.calculator.main.access$100(main.java:17)
    at com.calculator.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4340)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)


    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)


    What can the problem be?
     
  2. DonManfred

    DonManfred Expert Licensed User

  3. trueboss323

    trueboss323 Active Member Licensed User

    I think I figured out the problem,

    I was testing this on an emulator, so Google Play services was not available. But I tested it on a real device and it works fine.

    I do the calling in the sub Sub Activity_Create(FirstTime As Boolean)

    In this case, I have another question: How can i detect if Google Play is installed on the device, that way it disables all in-app purchasing features.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You need to handle the BillingSupported event and check the value of the Supported parameter.

    You can also add a try / catch block to catch this error (I'm not sure whether it will happen on a real device).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice