Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

in app purchase - Android inn app BillingFlowParams builder fails with java.lang.IllegalArgumentException

In my android app i have a pop up activity which appears in front of MainActivity with list of products to buy by user. When user chooses product - it calls MainActivity.launchBilling(String skuId)

Pop up activity:

recyclerViewDonate.addOnItemTouchListener(
            new RecyclerItemClickListener(this, recyclerViewDonate ,new RecyclerItemClickListener.OnItemClickListener() {
                @Override public void onItemClick(View view, int position) {
                    selectDonateSku = (String) list_sku_id.get(position);
                    MainActivity.launchBilling(selectDonateSku);
                    finish();
                }

                @Override public void onLongItemClick(View view, int position) {
                    selectDonateSku = (String) list_sku_id.get(position);
                    MainActivity.launchBilling(selectDonateSku);
                    finish();
                }
            })
    );

MainActivity:

public static void launchBilling(String skuId){
    BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
            .setSkuDetails(mSkuDetailsMap.get(skuId))
            .build();
    billingClient.launchBillingFlow(instance, billingFlowParams);
};

Sometines i receive error in report from production. It says that application crashed at BillingFlowParams builder. I cannot understand what could be the rootcause of this fail. Could someone please advise how to fix this?

Error:

java.lang.IllegalArgumentException: at com.android.billingclient.api.BillingFlowParams$Builder.build(com.android.billingclient:billing@@3.0.0:23)
at com.nosik.ochoforecasts.MainActivity.launchBilling (MainActivity.java:1136)
  at com.nosik.ochoforecasts.DonateActivity$1.onItemClick (DonateActivity.java:69)
  at com.nosik.ochoforecasts.RecyclerItemClickListener.onInterceptTouchEvent (RecyclerItemClickListener.java:34)
  at androidx.recyclerview.widget.RecyclerView.findInterceptingOnItemTouchListener (RecyclerView.java:3151)
  at androidx.recyclerview.widget.RecyclerView.dispatchToOnItemTouchListeners (RecyclerView.java:3122)
  at androidx.recyclerview.widget.RecyclerView.onTouchEvent (RecyclerView.java:3283)
  at android.view.View.dispatchTouchEvent (View.java:14376)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3857)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3535)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
  at com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:729)
  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1922)
  at android.app.Activity.dispatchTouchEvent (Activity.java:4051)
  at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:69)
  at com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:687)
  at android.view.View.dispatchPointerEvent (View.java:14644)
  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:6478)
  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:6265)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5703)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:5756)
  at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:5722)
  at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:5878)
  at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:5730)
  at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:5935)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5703)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:5756)
  at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:5722)
  at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:5730)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5703)
  at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:8862)
  at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:8723)
  at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:8676)
  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:8998)
  at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:194)
  at android.os.MessageQueue.nativePollOnce (Native Method)
  at android.os.MessageQueue.next (MessageQueue.java:336)
  at android.os.Looper.loop (Looper.java:197)
  at android.app.ActivityThread.main (ActivityThread.java:7814)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1068)```
question from:https://stackoverflow.com/questions/65935107/android-inn-app-billingflowparams-builder-fails-with-java-lang-illegalargumentex

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

"Could someone please advise how to fix this?"

The answer: we can not fix it as it is a problem with billingclient library. It has been already reported to google and classified as BUG, so we have to wait for a new version of billingclient library (newer than 3.02)

Click on the star on issuetracker page to let google know that you also have this issue: https://issuetracker.google.com/180032099


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...