Plugin.InAppBilling引发System.InvalidOperationException

时间:2019-05-24 09:26:44

标签: android xamarin xamarin.forms xamarin.android

我正在使用James Montemagno的Xamarin的Plugin.InAppBilling库。我可以在APP中购买商品。但是我有一个问题,当用户开始购买过程,然后单击后退按钮时,出现以下异常,该异常关闭了应用程序:

AndroidRuntime  android.runtime.JavaProxyThrowable: System.InvalidOperationException
at System.Threading.Tasks.TaskCompletionSource`1[TResult].SetException (System.Exception exception) [0x00013] in <480fb9ccca6544e8a794893d543d56d0>:0 
at Plugin.InAppBilling.InAppBillingImplementation.HandleActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x000bc] in <2be3ca88076242b5875e211410fe2dd3>:0 
at MyApp.MainActivity.OnActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x00009] in <4140b35e72414b0eb526cd2d93b76606>:0 
at Android.App.Activity.n_OnActivityResult_IILandroid_content_Intent_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 requestCode, System.Int32 native_resultCode, System.IntPtr native_data) [0x00014] in <1b54f667580d4c99805bc9e691b0d072>:0 
at (wrapper dynamic-method) System.Object.18(intptr,intptr,int,int,intptr)
at md5e55415e8d8604194587fc83b4c021d3d.MainActivity.n_onActivityResult(Native Method)
at md5e55415e8d8604194587fc83b4c021d3d.MainActivity.onActivityResult(MainActivity.java:38)
at android.app.Activity.dispatchActivityResult(Activity.java:7780)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4995)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5044)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:7539)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

我认为由于结果代码被抛出而引发的错误

Android.App.Result.Cancelled

如何停止此错误?还是应该更新OnActivityResult中的代码,使其忽略已取消的结果?

0 个答案:

没有答案