Current Android IAB reference

后端 未结 4 2033
悲&欢浪女
悲&欢浪女 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:53

    Hey I'm also working on InApp Purchase since 10 days and I've successfully integrated in my existing app and ready to make it live. Initially when i had started doing this I've downloaded google InApp Billing Example called "Trivial Drive" from here.

    But it didn't help me much as it has lots of issues and bugs, So I've decided do it on my own from scratch using new v3 api which you can find here. This tutorial has clear explanation that would help you and also if you have time see this youtube video where google employee had explained clearly how to integrate it.

    Also if you want quick example, I've a sample app which you can download from here. Feel free to ask if you have any questions.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-10 05:55

    You are probably using async operations. The current IabHelper is not safe in case you use the ...async methods. The problem is that in any moment an async operation is running dispose can be called on the main thread. In this case you will get NullPointerExceptions and IllegalStateExceptions.

    Try with this clone studiozanandroid

    With ref this Ans , download the patch here to avoid async errors.

    other than this checkout the signature validation issues like in this pay me lib,try to use OpenIAB libs.

    0 讨论(0)
  • 2021-02-10 06:15

    Whatever you do DO NOT USE IabHelper. This is a leftover from earlier versions of in app billing. This is not needed with version 3 as it introduces another layer and is buggy.

    Just go ahead and implement billing as shown in official docs - implementing in app billing.

    V3 of the API basically contains only three methods and is very straightforward to implement. If you are serious about in-app-billing then you have to understand how this process works anyway, no library or helper is going to help you with that.

    0 讨论(0)
提交回复
热议问题