Divyanshu Bhaskar
Divyanshu Bhaskar

Reputation: 345

MissingPluginException(No implementation found for method open on channel razorpay_flutter)

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):

I am getting this error while integrating the razorpay with flutter.I have written the code correctly or not.

  @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': '[email protected]'},
  '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);
}

At first i am getting error when initState() is called for all these three methods [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method open on channel razorpay_flutter)

then for second method

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method resync on channel razorpay_flutter)

and for the third method

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method resync on channel razorpay_flutter)

I have also added my razorpay_flutter correctly but when I click the button and call the method openCheckout() then missingPluginException occurs. How to fix this unhandled Exception error i have already called _razorpay.open(options) in try and catch block

Upvotes: 3

Views: 7106

Answers (6)

RITTIK
RITTIK

Reputation: 826

for me, I just used flutter clean and then built flutter build or flutter run, and it started working fine!

Upvotes: 0

Deep Technicals
Deep Technicals

Reputation: 1

I got the same issue and for me it did not work when built desktop APK or on simulator. But worked on real device by changing min sdk version 19

Upvotes: 0

Murat Kurbanov
Murat Kurbanov

Reputation: 837

I have faced same issue on another flutter package. The main reason of issue that after PUB GET new package, what use MethodChannels, you need to do next steps:

Uninstall the app from your device. Rebuild app again. This should solve the issue.

Upvotes: 2

Utsav Majhi
Utsav Majhi

Reputation: 21

After hours of searching I finally managed to get a proper solution for this: Step 1:make a file name of proguard-rules.pro inside android>app that should be : android/app/proguard-rules.pro then paste below code inside proguard-rules.pro file

 -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*(...);
}

Step 2: go to android>app>build.gradle and find buildTypes inside buildTypes>release add some lines

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'
    }
}

Step 3(IMP): Check your app is Signed perfectly using https://flutter.dev/docs/deployment/android If not then follow the steps in above url

PS: Used razorpay_flutter: 1.1.1

I hope this steps will solve the existing problem :)

Upvotes: 1

Abdul Malik
Abdul Malik

Reputation: 11

Roll back to version 1.1.1

or just replace the existing plugin with razorpay_flutter: 1.1.1

(make sure you do not have the ^ before the version number)

Upvotes: 1

Meir
Meir

Reputation: 1054

flutter clean, and restart, then it ok

I found it at: enter link description here and it worked fore me just fine.

Upvotes: 2

Related Questions