user2669743
user2669743

Reputation: 13

react native release apk crashes on RazorpayCheckout.open razorpay gateway

I am new to react-native and payment gateway and creating an android app, I am using "react": "16.9.0", "react-native": "0.60.5", "react-native-razorpay": "^2.1.30",

also i linked the using react-native link react-native-razorpay

and imported package as

import RazorpayCheckout from 'react-native-razorpay';

and calling gateway as :

    RazorpayCheckout.open(options).then((data) => {
       .............
        alert(`Success: ${JSON.stringify(data)}`);
    }).catch((error) => {
        alert(`Error: ${JSON.stringify(error)}`);
    });

the code works when i am running the app in debug mode, but when i create apk using bundleRelease and assembleRelease.

apk works fine until i try to make payment.

My conclusion : when apk goes to the RazorpayCheckout.open function call app crashes. I dont know how to debug that and hit a dead end here.

Upvotes: 1

Views: 1282

Answers (2)

sanjeev shetty
sanjeev shetty

Reputation: 458

I was having the same problem. I just disabled the progaurd rules. enableProguardInReleaseBuilds = false

Upvotes: 0

user7793540
user7793540

Reputation:

I was also facing the same issue as when I was canceling the Razor pay or when its going success app was crashing without any log.

The solution is simple:-

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

3 step

do the same as step 2 in debug also if you want to run APK in debug mode

Upvotes: 0

Related Questions