【问题标题】:Razor Pay with Xamarin Forms使用 Xamarin 表单进行剃须刀支付
【发布时间】:2020-07-12 16:13:44
【问题描述】:

我正在尝试将 Razor Pay 添加到我的 Xamarin 表单应用程序中,尽管我没有直接的方法从 aar 文件创建绑定库。 根据 Razor Pay 文档,我添加了几行代码,足以使用测试帐户,但我遇到了一个错误,我不知道如何解决它

这是抛出的异常

 com.google.android.gms.tasks.OnSuccessListener.onSuccess(java.lang.Object)

这是我的调用堆栈

07-12 21:36:07.276 D/com.razorpay.checkout( 9046): java.lang.AbstractMethodError: abstract method 
"void com.google.android.gms.tasks.OnSuccessListener.onSuccess(java.lang.Object)"
   07-12 21:36:07.276 D/com.razorpay.checkout( 9046):   at 
 com.google.android.gms.tasks.zzn.run(Unknown Source:4)
 07-12 21:36:07.276 D/com.razorpay.checkout( 9046):     at 
 android.os.Handler.handleCallback(Handler.java:873)
 07-12 21:36:07.276 D/com.razorpay.checkout( 9046):     at 
 android.os.Handler.dispatchMessage(Handler.java:99)

这是我已经实现的代码

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity, IPaymentResultWithDataListener, IOnSuccessListener, IOnFailureListener
{
    public App app;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(savedInstanceState);
        Checkout.Preload(this);
        Checkout checkOut = new Checkout();
        checkOut.SetKeyID("MyAPIKEY");
        Forms.SetFlags("IndicatorView_Experimental");
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        CachedImageRenderer.Init(true);
        Window.SetStatusBarColor(Android.Graphics.Color.Rgb(13, 141, 190));
        app = new App();
        LoadApplication(app);

        if (IsPlayServiceAvailable() == false)
        {
            throw new System.Exception("This device does not have Google Play Services and cannot receive push notifications.");
        }
        CreateNotificationChannel();
        LoginWithSocialIconViewModel.AuthenticateAction += OAuthGoogle;
        Window.SetSoftInputMode(Android.Views.SoftInput.AdjustResize);

        Activity activity = this;
        JSONObject options = new JSONObject();
        options.Put("description", "My Sample Payment activity");
        options.Put("order_id", "order_EAMgUyLXrMfbmL");
        options.Put("currency", "INR");
        options.Put("amount", "100");
        checkOut.Open(activity, options);
    }

谁能弄清楚我错过了什么

【问题讨论】:

  • 您可能需要更新您的 google play 服务包,它可能不兼容。你用的是什么版本,razor pay推荐什么版本?
  • @Saamer 我将结帐 arr 文件降级到 1.5.18 到 1.5.14 并且它工作了

标签: xamarin xamarin.forms xamarin.android razorpay


【解决方案1】:

只需将其粘贴在这里,我们就可以结束问题了。

每当您的 google play 服务包与您尝试添加的库不兼容时,您就会收到此错误 java.lang.AbstractMethodError: abstract method "void com.google.android.gms.tasks.OnSuccessListener.onSuccess(java.lang.Object)"

因此,您要么必须更改 Google Play 服务包的版本,要么更改 AAR 库文件的版本。

【讨论】:

  • 我降级了我的 AAR 文件版本,它运行良好,但我的 Google Play 服务已更新到最新我如何确定哪个版本的 Google Play 服务与我的 AAR 库文件兼容?
  • 你得看看AAR库文件的细节。检查它正在使用哪个版本的 Play Services 库
猜你喜欢
  • 2018-08-21
  • 1970-01-01
  • 2013-04-04
  • 2021-10-22
  • 1970-01-01
  • 1970-01-01
  • 2013-02-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多