gpt4 book ai didi

android - Razorpay 在支付页面崩溃,在 flutter 中找不到类 "com.razorpay.d__1_"

转载 作者:行者123 更新时间:2023-11-30 04:58:32 25 4
gpt4 key购买 nike

我正在使用这个插件 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)

最佳答案

我只是按照下面的步骤来解决这个问题。

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 正在运行。

关于android - Razorpay 在支付页面崩溃,在 flutter 中找不到类 "com.razorpay.d__1_",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58706014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com