Skip to content

The constructor of AndroidHttpHandler should be preserved together with AndroidMessageHandler #6949

@huoyaoyuan

Description

@huoyaoyuan

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET SDK 6.0.202, Runtime 6.0.4

Description

Xamarin.Android.Net.AndroidHttpHandler was used for Xamarin android applications, and is set when using Visual Studio project setting UI.
However, only the new AndroidMessageHandler is preserved:

https://github.com/xamarin/xamarin-android/blob/bacc3f0282b05978f1cde13f0ca49ecc58048efe/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs#L342-L348

When using HttpClientHandler with a migrated application, it crashes hardly in Debug configuration, and throws NullReferenceException in Release configuration. It's quite hard to debug for people unfamiliar with how http client handler works.

Steps to Reproduce

Use <AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidHttpHandler</AndroidHttpClientHandlerType> in any minimal application, and use HttpClientHandler.

Did you find any workaround?

I browsed the code path setting up native handler, and realized only AndroidMessageHandler would work.

Relevant log output

No response

Metadata

Metadata

Labels

Area: LinkerIssues when linking assemblies.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions