Я использую этот плагин https://pub.dev/packages/razorpay_flutter
flutter run
отлично работает в эмуляторе и реальном устройстве. но после flutter build apk
приложение Crashed на _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);
}
в визуальномкод терминала студии
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 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)
решено
просто добавление правил про охрану в флаттере
https://github.com/razorpay/razorpay-flutter/issues/42#issuecomment-550161626