Error while using stripe android sdk native interopt

Haider Ali Faizi 100 Reputation points
2025-01-21T20:34:23.2733333+00:00

I am trying to bind stripe sdk of android in .net maui. I try template and it works fine. But, when i try it, it is binding and when i call , it gets me NewBindingAndroid.StripeIntegration.NewStripeIntegration(Platform.CurrentActivity);:"{Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/stripe/android/paymentsheet/PaymentSheet; ---> Java.Lang.ClassNotFoundException: Didn't find class "com.stripe.android.paymentsheet.PaymentSheet" on path: DexPathList[[zip file "/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/lib/arm64, /data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64]]

--- End of managed Java.Lang.ClassNotFoundException stack trace --- java.lang.ClassNotFoundException: Didn't find class "com.stripe.android.paymentsheet.PaymentSheet" on path: DexPathList[[zip file "/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/lib/arm64, /data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.example.newbinding.StripeIntegration.newStripeIntegration(StripeIntegration.java:21) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29) at android.view.View.performClick(View.java:7317) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1218) at android.view.View.performClickInternal(View.java:7291) at android.view.View.access$3600(View.java:838) at android.view.View$PerformClick.run(View.java:28247) at android.os.Handler.handleCallback(Handler.java:900) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8676) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

--- End of managed Java.Lang.ClassNotFoundException stack trace --- java.lang.ClassNotFoundException: Didn't find class "com.stripe.android.paymentsheet.PaymentSheet" on path: DexPathList[[zip file "/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/lib/arm64, /data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.example.newbinding.StripeIntegration.newStripeIntegration(StripeIntegration.java:21) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29) at android.view.View.performClick(View.java:7317) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1218) at android.view.View.performClickInternal(View.java:7291) at android.view.View.access$3600(View.java:838) at android.view.View$PerformClick.run(View.java:28247) at android.os.Handler.handleCallback(Handler.java:900) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8676) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

--- End of inner exception stack trace --- at Java.Interop.JniEnvironment.StaticMethods.CallStaticVoidMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net8.0/JniEnvironment.g.cs:line 21831 at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeVoidMethod(String encodedMember, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:line 111 at NewBindingAndroid.StripeIntegration.NewStripeIntegration(Activity _activity) in C:\Users\Haider Ali\Downloads\Maui.NativeLibraryInterop-main (1)\template\android\NewBinding.Android.Binding\obj\Debug\net9.0-android\generated\src\NewBindingAndroid.StripeIntegration.cs:line 171 at MauiSample.MainPage.StripeIntegration.InitializePayment(String publishableKey, String customerId, String ephemeralKey, String paymentIntent) in C:\Users\Haider Ali\Downloads\Maui.NativeLibraryInterop-main (1)\template\sample\MainPage.xaml.cs:line 47 at MauiSample.MainPage.OnDocsButtonClicked(Object sender, EventArgs e) in C:\Users\Haider Ali\Downloads\Maui.NativeLibraryInterop-main (1)\template\sample\MainPage.xaml.cs:line 27 --- End of managed Java.Lang.NoClassDefFoundError stack trace --- java.lang.NoClassDefFoundError: Failed resolution of: Lcom/stripe/android/paymentsheet/PaymentSheet; at com.example.newbinding.StripeIntegration.newStripeIntegration(StripeIntegration.java:21) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29) at android.view.View.performClick(View.java:7317) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1218) at android.view.View.performClickInternal(View.java:7291) at android.view.View.access$3600(View.java:838) at android.view.View$PerformClick.run(View.java:28247) at android.os.Handler.handleCallback(Handler.java:900) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8676) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.stripe.android.paymentsheet.PaymentSheet" on path: DexPathList[[zip file "/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/lib/arm64, /data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 15 more

--- End of managed Java.Lang.NoClassDefFoundError stack trace --- java.lang.NoClassDefFoundError: Failed resolution of: Lcom/stripe/android/paymentsheet/PaymentSheet; at com.example.newbinding.StripeIntegration.newStripeIntegration(StripeIntegration.java:21) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method) at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29) at android.view.View.performClick(View.java:7317) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1218) at android.view.View.performClickInternal(View.java:7291) at android.view.View.access$3600(View.java:838) at android.view.View$PerformClick.run(View.java:28247) at android.os.Handler.handleCallback(Handler.java:900) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8676) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.stripe.android.paymentsheet.PaymentSheet" on path: DexPathList[[zip file "/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/lib/arm64, /data/app/com.companyname.mauisample-f8V3J1SyqfgKxb0oLjTwZA==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 15 more }" . Because when i try to add stripe library using AndroidMavenlibrary, it has a lot of dependencies issue. So, i prefer it. But, getting that error. My code is here:

https://drive.google.com/file/d/1FZd8Nbb8EPD5cezqoKUS_1I66QWxVHju/view?usp=drive_link

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,372 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,067 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,864 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.