Current Android IAB reference

后端 未结 4 2035
悲&欢浪女
悲&欢浪女 2021-02-10 05:50

I\'ve been struggling with Android IAB v3 for a while now. I have it working consistently on my test devices. However, my crash reporting service shows two recurring crashes: on

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-10 05:55

    The first IllegalStateException is occurring because the previously launched operation using IAB Helper is yet to complete.

    Probable causes:

    1. Forgot to call mHelper.dispose() in onDestroy() of activity.
    2. If you are launching purchase on button click rapidly double tapping the button on some device will produce the crash.

    In your case you are trying to query inventory when already a launchPurchase is progress.

    Solution: The status of async operation is reflected in variable mAsyncInProgress in IabHelper. You will have to change the scope of the variable to public, it package by default. You can then take either of the two approaches after querying the variable:

    Make sure you have called mHelper.dispose() in onDestroy() of activity.

    1. cancel the current operation and start the new operation ignore the

    or

    1. current request if any operation is running.

    The exception is thrown in flagStartAsync function.

    To figure our the root cause of the NullPointerException you will have to provide the code for launchPurchasFlow with line numbers.

    Other precautions you should take: To avoid "IAB helper is not set up. Can't perform operation:launchPurchaseFlow which is caused when you call launchPurchaseFlow before IabHelper setup is complete.

    You can disable the buy button by default. Enable the button on onIabSetupFinished callback of the IabHelper. Therefore the button will work only when the IabHelper setup is complete.

提交回复
热议问题