android: Net7-android binding has ClassNotFoundException when trying to consume
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 17.6.3, net7.0-android
Description
I have a net7.0-android binding project created here: https://github.com/Envoc/envoc-stripe-binding/blob/android-2.19.0/src/StripeTerminal/Envoc.Stripe.Terminal.Android/Envoc.Stripe.Terminal.Android.csproj With a nuget package here: https://www.nuget.org/packages/Envoc.Stripe.Terminal.Android.
Adding that nuget package and trying to consume the library via the line Com.Stripe.Stripeterminal.Terminal.IsInitialized; from a File -> New Maui Project app causes the exception java.lang.ClassNotFoundException: Didn't find class "com.stripe.jvmcore.logging.terminal.log.Log"
It looks like that class is in com.stripe_stripeterminal-internal-common.aar under the libs folder.
Android binding troubleshooting says to add a missing jar file, but this is a lib of an included aar. Is this a packaging issue?
Steps to Reproduce
- Create new Maui app
- Add nuget reference to
Envoc.Stripe.Terminal.Android - In the click me button add a call to the nuget like
Com.Stripe.Stripeterminal.Terminal.IsInitialized;
Did you find any workaround?
No
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (11 by maintainers)
For now, I think we can close, as we have the two PRs that should fix this in .NET 8:
We’ll consider backporting to .NET 7, so anyone upvote or comment if you run into this. It will help us know how important it is to backport these. Thanks!
Can confirm that using the two workarounds allowed the additional
.aars to be included in the nuget:Yeah, I initially was going to service this fix to .NET 7, but it caused other issues, ended up being two fixes:
If we don’t find any further issues with these, maybe we could take them both back to .NET 7?
For now as a workaround, you could do something like adding a
<None/>entry mentioned here: https://github.com/xamarin/xamarin-android/issues/8190#issuecomment-1638856266And also set
Pack="true" PackagePath="lib/net7.0-android33.0"to get the file in the right location in the.nupkgfile.