Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes instead of open razorpay payment page in flutter #42

Closed
yashdabi opened this issue Nov 4, 2019 · 19 comments
Closed

App crashes instead of open razorpay payment page in flutter #42

yashdabi opened this issue Nov 4, 2019 · 19 comments

Comments

@yashdabi
Copy link

yashdabi commented Nov 4, 2019

flutter run is working fine in the emulator and real device.
but after flutter build apk, the app Crashed on _razorpay.open(options);
and the plugin is not showing a crash report or any error in the visual studio code terminal.

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

  var options = {
      'key': 'rzp_test_xxxxxxx',
      'amount': 100, //in the smallest currency sub-unit.
      'name': 'Acme Corp.',
      'description': 'Fine T-Shirt',
      'prefill': {'contact': '9123456789', 'email': '[email protected]'}
    };

    print('0');
 try {
      print('1');
      _razorpay.open(options);
      print('2');
    } catch (e) {
      print('error');
      debugPrint(e);
    }

in the visual studio code terminal

11-05 00:22:29.197 21170 21209 I flutter : 0
11-05 00:22:29.197 21170 21209 I flutter : 1
11-05 00:22:29.197 21170 21209 I flutter : 2

In the Andoid studio logcat
java.lang.ClassNotFoundException: Didn't find class "com.razorpay.d__1_"

2019-11-05 11:59:49.168 30159-30159/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.my_task, PID: 30159
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.my_task/com.razorpay.CheckoutActivity}: 
java.lang.ClassNotFoundException: Didn't find class "com.razorpay.d__1_" on path: DexPathList[[zip file "/data/app/com.example.my_task-OX9pWhAo1dl4QP0DQBF58w==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my_task-OX9pWhAo1dl4QP0DQBF58w==/lib/arm64, /data/app/com.example.my_task-OX9pWhAo1dl4QP0DQBF58w==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6944)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.razorpay.d__1_" on path: DexPathList[[zip file "/data/app/com.example.my_task-OX9pWhAo1dl4QP0DQBF58w==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my_task-OX9pWhAo1dl4QP0DQBF58w==/lib/arm64, /data/app/com.example.my_task-OX9pWhAo1dl4QP0DQBF58w==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.razorpay.Y_$B$.Q_$2$(:1112)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.razorpay.A.<clinit>(:204)
        at com.razorpay.A.a(Unknown Source:0)
        at com.razorpay.c.b(:189)
        at com.razorpay.h.b(:412)
        at com.razorpay.ja.onCreate(:82)
        at com.razorpay.u.onCreate(:23)
        at com.razorpay.CheckoutActivity.onCreate(:8)
        at android.app.Activity.performCreate(Activity.java:7183)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
@ashutoshxhq
Copy link

Same issue with my implementation

@sharad-paghadal
Copy link

@idkashutosh try this - https://pub.dev/packages/razorpay_plugin

@ashutoshxhq
Copy link

Fixed it by adding the proguard rules in android

@ashutoshxhq
Copy link

ashutoshxhq commented Nov 6, 2019

@yashdabi Try adding proguard rules as shown in razorpay docs. https://razorpay.com/docs/payment-gateway/android-integration/standard/ Also if you are doing release build, do sign the apk by following the flutter release build guide. https://flutter.dev/docs/deployment/android

@yashdabi
Copy link
Author

yashdabi commented Nov 6, 2019

@yashdabi Try adding proguard rules as shown in razorpay docs. https://razorpay.com/docs/payment-gateway/android-integration/standard/ Also if you are doing release build, do sign the apk by following the flutter release build guide. https://flutter.dev/docs/deployment/android

@idkashutosh thanks, it's working
I just following below steps for this solution.

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

2 step
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.debug
            minifyEnabled true
            useProguard true 
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

now Razorpay is working.

@Vickycp
Copy link

Vickycp commented Jul 3, 2020

thanks bro

@yashpaneliya
Copy link

Thank you so much @yashdabi 🚀🚀

@Sagar6133
Copy link

i m aslo facing same problem and i ahve added proguard rules ... did not worked ..the api key is test key ... it is woring with debug version, not working with release version

can anyone guide please

@Sagar6133
Copy link

can anyone help please , how it will be fixed

@sumedht
Copy link
Contributor

sumedht commented Oct 21, 2020

Closing this issue due to no further response. Please feel free to either re-open the issue or create a new issue if you have any additional queries.

@sumedht sumedht reopened this Oct 21, 2020
@adamshamsudeen
Copy link

In the documentation, it says "If you are using proguard for your builds" use the following. But looks like progaurd is necessary, without which I'm getting this error. Can we mention it that way in the documentaion?

@vijaypareek13
Copy link

I have integrated razorpay in flutter web but facing the same problem. Please anyone here to help me

@rohan220217
Copy link

rohan220217 commented Aug 12, 2021

I have done everything like I have added progaurd rule and also mentioned it in gradle file but still, in production mode, the checkout button becomes an infinite white screen. I am using the test key. Please help!

@yashdabi
Copy link
Author

@rohan220217 what error is showing in Logcat after opening the Razorpay

try this to see Logcat messages
https://stackoverflow.com/questions/58693539/how-to-see-debug-console-when-app-installed-through-apk-in-flutter

@rohan220217
Copy link

@rohan220217 what error is showing in Logcat after opening the Razorpay

try this to see Logcat messages
https://stackoverflow.com/questions/58693539/how-to-see-debug-console-when-app-installed-through-apk-in-flutter

Thank you very much @yashdabi but I fixed my error while debugging. The checkout button becomes grey infinite screen because I have used incorrect parent widget

@TusharKhari
Copy link

As I used razor pay plugin today and it showed me some this signature error :

  • What went wrong:
    A problem occurred evaluating project ':app'.

No signature of method: build_1qfv6up9v4rgk8kbzjky2agc8.android() is applicable for argument types: (build_1qfv6up9v4rgk8kbzjky2agc8$_run_closure2) values: [build_1qfv6up9v4rgk8kbzjky2agc8$_run_closure2@4b270c5a]

so fixed this error by commenting "useProguard true" in android/app/build.gradle and it worked for me

@ameenulislam
Copy link

ameenulislam commented May 6, 2024

If you tried everything and nothing worked!

Accrording to razorpay docs, you should create an order in the server (probably using an API) before calling razorpay.open(Options).
It is important that the order_id you are sending should match with one you get in response while you created an order earlier

This only applies if you are sending an order_id in your razorpay options

@sai-phaneesh
Copy link

@yashdabi Try adding proguard rules as shown in razorpay docs. https://razorpay.com/docs/payment-gateway/android-integration/standard/ Also if you are doing release build, do sign the apk by following the flutter release build guide. https://flutter.dev/docs/deployment/android

@idkashutosh thanks, it's working I just following below steps for this solution.

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

2 step 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.debug
            minifyEnabled true
            useProguard true 
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

now Razorpay is working.

For me removing the useProguard in build.gradle worked properly.

    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.debug
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

@chhand2808
Copy link

@yashdabi Try adding proguard rules as shown in razorpay docs. https://razorpay.com/docs/payment-gateway/android-integration/standard/ Also if you are doing release build, do sign the apk by following the flutter release build guide. https://flutter.dev/docs/deployment/android

@idkashutosh thanks, it's working I just following below steps for this solution.
1 step 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*(...);
}

2 step 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.debug
            minifyEnabled true
            useProguard true 
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

now Razorpay is working.

For me removing the useProguard in build.gradle worked properly.

    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.debug
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

This worked for me, great, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests