Razorpay在付款页面上崩溃,未在扑扑中找到类“ com.razorpay.d__1_”

时间:2019-11-05 06:59:41

标签: android flutter flutter-dependencies razorpay

我正在使用此插件https://pub.dev/packages/razorpay_flutter
Razorpay在付款页面上崩溃

flutter run在仿真器和真实设备中运行正常。 但在flutter build apk之后,该应用在_razorpay.open(options);崩溃了 并且该插件未在Visual Studio代码终端中显示崩溃报告或任何错误。

  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': 'test.kumar@example.com'}
    };

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

在Visual Studio代码终端中

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

在Andoid Studio Logcat中

java.lang.ClassNotFoundException:找不到类“ 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)

2 个答案:

答案 0 :(得分:0)

我只是按照以下步骤进行操作。

1步
android> app
中创建 proguard-rules.pro 文件名 应该是: android / app / proguard-rules.pro
proguard-rules 文件中添加以下行

-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> app> build.gradle并找到 buildTypes
在buildTypes> release内部添加一些行

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

现在Razorpay正在运行。

答案 1 :(得分:0)

我遇到了同样的问题,尝试了几天,最后我换到了 razorpay 1.6.11 的最新版本(2021 年 8 月 11 日),尝试不同的版本,它会工作