当前位置: 首页 > 知识库问答 >
问题:

找不到在通道razorpay_flutter打开方法的实现

公西天逸
2023-03-14
Reloaded 7 of 542 libraries in 1,099ms.
E/flutter ( 1062): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method open on channel razorpay_flutter)
[38;5;244mE/flutter ( 1062): #0      MethodChannel.invokeMethod[39;49m
E/flutter ( 1062): <asynchronous suspension>
[38;5;248mE/flutter ( 1062): #1      Razorpay.open    (package:razorpay_flutter/razorpay_flutter.dart:48:35)[39;49m
[38;5;248mE/flutter ( 1062): #2      _BuyBidsState.openCheckout[39;49m
[38;5;248mE/flutter ( 1062): #3      _BuyBidsState.getBidsData.<anonymous closure>[39;49m
[38;5;244mE/flutter ( 1062): #4      _InkResponseState._handleTap[39;49m
[38;5;244mE/flutter ( 1062): #5      _InkResponseState.build.<anonymous closure>[39;49m        
[38;5;244mE/flutter ( 1062): #6      GestureRecognizer.invokeCallback[39;49m
[38;5;244mE/flutter ( 1062): #7      TapGestureRecognizer.handleTapUp[39;49m
[38;5;244mE/flutter ( 1062): #8      BaseTapGestureRecognizer._checkUp[39;49m
[38;5;244mE/flutter ( 1062): #9      BaseTapGestureRecognizer.acceptGesture[39;49m
[38;5;244mE/flutter ( 1062): #10     GestureArenaManager.sweep[39;49m
[38;5;244mE/flutter ( 1062): #11     GestureBinding.handleEvent[39;49m
[38;5;244mE/flutter ( 1062): #12     GestureBinding.dispatchEvent[39;49m
[38;5;244mE/flutter ( 1062): #13     GestureBinding._handlePointerEvent[39;49m
[38;5;244mE/flutter ( 1062): #14     GestureBinding._flushPointerEventQueue[39;49m
[38;5;244mE/flutter ( 1062): #15     GestureBinding._handlePointerDataPacket[39;49m
[38;5;244mE/flutter ( 1062): #16     _rootRunUnary  (dart:async/zone.dart:1138:13)[39;49m
[38;5;244mE/flutter ( 1062): #17     _CustomZone.runUnary  (dart:async/zone.dart:1031:19)    [39;49m
[38;5;244mE/flutter ( 1062): #18     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:933:7)[39;49m
[38;5;244mE/flutter ( 1062): #19     _invoke1  (dart:ui/hooks.dart:273:10)[39;49m
[38;5;244mE/flutter ( 1062): #20     _dispatchPointerDataPacket  (dart:ui/hooks.dart:182:5)[39;49m
E/flutter ( 1062):

我得到这个错误,而集成razorPay与flutter。我写的代码正确与否。

  @override
  void initState() {
  super.initState();

 _razorpay = Razorpay();
 _razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
 _razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
 _razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);
}

@override
void dispose() {
super.dispose();
_razorpay.clear();
}

 void openCheckout() async {
 var options = {
  'key': 'rzp_test_geinuADCB6Csdb',
  'amount': 10*100,
  'name': 'BidAnd2Win',
  'description': 'Buying Bid to play game',
  'prefill': {'contact': '8888888888', 'email': 'test@razorpay.com'},
  'external': {
    'wallets' : ['paytm'],
  }
 };
try{
 _razorpay.open(options);
}
catch(e) {
  debugPrint(e);
}

}

void _handlePaymentSuccess(PaymentSuccessResponse response) {
  Fluttertoast.showToast(msg: 'Success' + response.paymentId);
}

void _handlePaymentError(PaymentFailureResponse response) {
  Fluttertoast.showToast(msg: 'Failure' + response.code.toString() + " - " + response.message);
}

void _handleExternalWallet(ExternalWalletResponse response) {
  Fluttertoast.showToast(msg: 'Sucess Wallet payment' + response.walletName);
}

首先,当为所有这三个方法调用initState()时,我遇到了一个错误[error:flatter/lib/ui/ui\u dart\u state.cc(157)]未处理的异常:MissingPluginException(在通道razorpay\u flatter上未找到打开的方法的实现)

然后是第二种方法

[错误:flatter/lib/ui/ui_dart_state.cc(157)]未处理的异常:缺少PluginException(在通道razorpay_flatter上未找到方法resync的实现)

第三种方法呢

[错误:flatter/lib/ui/ui_dart_state.cc(157)]未处理的异常:缺少PluginException(在通道razorpay_flatter上未找到方法resync的实现)

我还正确地添加了razorpay_flatter,但当我单击按钮并调用方法openCheckout()时,就会发生missingPluginException。如何修复这个我已经调用过的未处理的异常错误。在try and catch块中打开(选项)

共有3个答案

刘选
2023-03-14

经过数小时的搜索,我终于找到了一个合适的解决方案:步骤1:为proguard规则创建一个文件名。Android系统内部的pro

 -keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

-keepattributes JavascriptInterface
-keepattributes *Annotation*

-dontwarn com.razorpay.**
-keep class com.razorpay.** {*;}

-optimizations !method/inlining/*

-keepclasseswithmembers class * {
  public void onPayment*(...);
}

步骤2:去android

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.release
        minifyEnabled false
        useProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

步骤3(IMP):检查您的应用程序是签署完美使用https://flutter.dev/docs/deployment/android如果不是,然后按照上面的步骤url

PS:使用过的razorpay_颤振:1.1。1.

我希望这些步骤能够解决现有的问题:)

艾嘉石
2023-03-14

回滚到1.1版。1.

或者用razorpay_flatter:1.1替换现有的插件。1.

(请确保版本号前没有“^”)

庄阿苏
2023-03-14

颤振清洁,然后重新启动,然后就可以了

我发现它在:输入链接描述在这里,它对我的工作刚刚好。

 类似资料: