Closed rbakhshi closed 8 months ago
Hi @rbakhshi , thank you for reporting this. We have started investigating and will let you know what we find.
This issue has been logged internally as 221860 and is still being investigated.
@rbakhshi , we have been able to reproduce the issue and are currently evaluating options to handle the underlying AndroidX vs. Android.Support.v4 compatibility in the ecosystem.
To provide us confirmation, if you add the Xamarin.AndroidX.Migration
package to your project, does your build error get resolved? You may need to clean your project.
Thanks @tanderson-ld, currently out of office. Will check when I get back.
ok @tanderson-ld I can confirm that at least the build error is now gone. For some "technical" reasons I cannot test the actual runtime behaviour right now.
I needed to add these to the project file:
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.10" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.13" />
</ItemGroup>
Thank you for looking into that and confirming it builds! We are still discussing this internally. Are those dependencies satisfactory for you as a work around for the moment?
Would you mind also letting us know if with those migration dependencies in place, do you still see the Only AndroidMessageHandler is supported for AndroidClientHandler
error at runtime?
OK tested the new build and unfortunately still fails with similar error. Here is the error when running v4.0.0 sdk with above Xamarin.AndroidX.Migration
package:
FATAL EXCEPTION: main
Process: xxxx, PID: 12953
android.runtime.JavaProxyThrowable: System.InvalidOperationException: Unknown underlying handler. Only AndroidMessageHandler is supported for AndroidClientHandler
at Xamarin.Android.Net.AndroidClientHandler..ctor()
at LaunchDarkly.Sdk.Client.PlatformSpecific.Http.<>c__DisplayClass2_0.<PlatformGetHttpMessageHandlerFactory>b__0(HttpProperties p)
at LaunchDarkly.Sdk.Internal.Http.HttpProperties.NewHttpClient()
at LaunchDarkly.Sdk.Internal.Events.DefaultEventSender..ctor(HttpProperties httpProperties, EventsConfiguration config, Logger logger)
at LaunchDarkly.Sdk.Client.Integrations.EventProcessorBuilder.Build(LdClientContext context)
at LaunchDarkly.Sdk.Client.LdClient..ctor(Configuration configuration, Context initialContext, TimeSpan startWaitTime)
at LaunchDarkly.Sdk.Client.LdClient.CreateInstance(Configuration configuration, Context initialContext, TimeSpan maxWaitTime)
at LaunchDarkly.Sdk.Client.LdClient.Init(Configuration config, Context initialContext, TimeSpan maxWaitTime)
@rbakhshi , I still need to investigate that InvalidOperationException
. I've been treating them as two separate errors for the moment. Will look into that one once we have the first error corrected.
@rbakhshi , we've decided we're going to update our implementation to stop using monoandroid and begin using .netX.X-android. Still investigating exactly which .netX.X-android version we will use to make sure we maintain compatibility for customers. Are you currently shipping a MAUI app that was using LaunchDarkly Dotnet Client v3.1.0? Or perhaps this is a first attempt at using Launch Darkly in your application?
@tanderson-ld we have a xamarin app using LD client which we are porting to. Net 8 and Maui. (Considering the xamarin end of life approaching)
@rbakhshi , we are planning to target net7.0 for our library which I believe will be compatible with your project. Would you be interested in alpha testing a distribution when we have our first alpha ready? Hopefully within the next week.
Yes, I would be interested! Thanks
@rbakhshi , just wanted to keep you updated. The last thing I need to do to make the alpha is to update our build and CI infrastructure. That should be the last step. I'll reach back out when I have the alpha.
Awesome news! Thanks @tanderson-ld
Just an update here: I've been referencing v4 in the app but commented out the initialization part. (Just to run the rest of app without launchdarkly). This was all fine.
Running Release though, will still fail on Android Linker step. Removing reference to launchdarkly nuget stops the linker failure.
this issue (https://github.com/xamarin/xamarin-android/issues/8208) made me suspect it could be related to launchdarkly's current nuget package
@rbakhshi , I haven't forgotten about you! Juggling a few different priorities at the moment.
We were using ClientSdk v3.1 and upgraded our solution to .Net 8 and this package to v4.0. After also running into the compiler error mentioned above, I reverted back to v3.1 and the app compiles now but crashes on startup. Not sure if it's related to this lib or not.
Has anyone else been able to get LaunchDarkly.ClientSdk v3.1 to work with .Net 8 Android?
A significant slowdown was caused by refactoring of our CI/CD test frameworks to use Maui, but we just got unblocked on that technical issue, so hopefully we get to an alpha soon.
Hi @rbakhshi , we just put the alpha up on Nuget. The version is 5.0.0-alpha.1
. Sorry for the inaccurate estimate originally. Please let us know if you run into any issues! Thank you again for your patience.
Hi @tanderson-ld thanks for the update.
Unfortunately I am getting the same error even with 5.0.0-alpha.1
release:
System.InvalidOperationException: Unknown underlying handler. Only AndroidMessageHandler is supported for AndroidClientHandler
at Xamarin.Android.Net.AndroidClientHandler..ctor() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:line 70
at LaunchDarkly.Sdk.Client.PlatformSpecific.Http.<>c__DisplayClass2_0.<PlatformGetHttpMessageHandlerFactory>b__0(HttpProperties p)
at LaunchDarkly.Sdk.Internal.Http.HttpProperties.NewHttpClient()
at LaunchDarkly.Sdk.Internal.Events.DefaultEventSender..ctor(HttpProperties httpProperties, EventsConfiguration config, Logger logger)
at LaunchDarkly.Sdk.Client.Integrations.EventProcessorBuilder.Build(LdClientContext context)
at LaunchDarkly.Sdk.Client.LdClient..ctor(Configuration configuration, Context initialContext, TimeSpan startWaitTime)
at LaunchDarkly.Sdk.Client.LdClient.CreateInstance(Configuration configuration, Context initialContext, TimeSpan maxWaitTime)
at LaunchDarkly.Sdk.Client.LdClient.Init(Configuration config, Context initialContext, TimeSpan maxWaitTime)
I do see a warning in our build related to the deprecation of AndroidClientHandler, but I haven't been able to reproduce the runtime exception you are encountering. I can update from AndroidClientHandler to AndroidMessageHandler and put out a new alpha to see if that addresses the problem for you.
What Android API level are you targeting with your app?
@rbakhshi , could you provide a snippet with your Configuration
setup? I'd like to test with as similar a setup.
We released version 5.0.0-alpha.2 which uses the AndroidMessageHandler
instead. I haven't been able to reproduce the issue unfortunately.
Hi @tanderson-ld , thanks for the update. I tested a clean new project and even alpha1 seems to work. That is great. Now I need to check why I still get that above error.
I will try alpha2 in a bit and update you
ok I can confirm that alpha.2
works fine for us. thanks @tanderson-ld
Great! Thank you for your patience while we resolved it. Please let us know if you see any other issues!
@tanderson-ld when targeting API 34 for android, the app fails when initializing launch darkly:
Seems like related to this: https://github.com/dotnet/maui/issues/17861
System.TypeInitializationException: The type initializer for 'LaunchDarkly.Sdk.Client.PlatformSpecific.PlatformConnectivity' threw an exception.
---> Java.Lang.SecurityException: com.my.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
---> Android.OS.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
at android.os.Binder.execTransactInternal(Binder.java:1339)
at android.os.Binder.execTransact(Binder.java:1275)
--- End of managed Android.OS.RemoteException stack trace ---
android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
at android.os.Binder.execTransactInternal(Binder.java:1339)
at android.os.Binder.execTransact(Binder.java:1275)
--- End of managed Android.OS.RemoteException stack trace ---
android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
at android.os.Binder.execTransactInternal(Binder.java:1339)
at android.os.Binder.execTransact(Binder.java:1275)
--- End of inner exception stack trace ---
at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualObjectMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)
at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters)
at Android.Content.ContextWrapper.RegisterReceiver(BroadcastReceiver receiver, IntentFilter filter)
at Microsoft.Maui.Networking.ConnectivityImplementation.StartListeners()
at Microsoft.Maui.Networking.ConnectivityImplementation.add_ConnectivityChanged(EventHandler`1 value)
at LaunchDarkly.Sdk.Client.PlatformSpecific.PlatformConnectivity..cctor()
--- End of managed Java.Lang.SecurityException stack trace ---
java.lang.SecurityException: com.my.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
at android.os.Parcel.createException(Parcel.java:3041)
at android.os.Parcel.readException(Parcel.java:3024)
at android.os.Parcel.readException(Parcel.java:2966)
at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
at android.os.Binder.execTransactInternal(Binder.java:1339)
at android.os.Binder.execTransact(Binder.java:1275)
Hi again @rbakhshi. Just to confirm, is it the case that you do NOT encounter this issue on LD Dotnet SDK 5.0.0 and Android target API 33? Just want to make sure this truly only happens when switching to target API 34. I'm catching up on that other issue you sent, thank you for doing some digging.
Correct. Using v5.0.0 and API 33 is fine
I raised a separate bug for this here https://github.com/launchdarkly/dotnet-client-sdk/issues/89
Is this a support request? no
Describe the bug Support for .NET 8 seems to be broken (at least in case of Android)
To reproduce
Error details:
I suspect the issue is due to references to Xamarin dependencies which are no longer valid for MAUI apps. Below is list of dependencies installed by LaunchDarkly.ClientSdk
Also, you can try using v3.1.0. The application starts but
LdClient.Init
fails with following exception:Expected behavior The application should build without any issues.
Logs I think I added the stack trace
SDK version version 4.0.0 Also tried version 3.1.0 and it allows building the project but fails at runtime (Exception details above)
Language version, developer tools .NET 8.0.100-rc.2.23502.2
OS/platform Windows 10
Additional context Add any other context about the problem here.