Xamarin Forms PCL HttpClient throws unhandled exception on Android

I use System.Net.Http.HttpClient directly in PCL Xamarin.Forms. Although it works fine on Windows Phone, on Android it throws an unhandled exception on the GetAsync line.

Is there any specific platform that I don't see?

var client = new HttpClient(); var response = await client.GetAsync(Constants.ProjectsUri); // this breaks 
+5
source share
1 answer

Use native client application handler for Android

In the Android Build settings, install the HttpClient Implementation to use the AndroidClientHandler .

Xamarin documentation link

The AndroidClientHandler class was introduced in Xamarin.Android 6.1 to support TLS 1.2 for Xamarin.Android applications. This class uses the native java.net.URLConnection for all HTTP connections, allowing the HttpClient instance to use any network and encryption protocols available for Android.

enter image description here

+1
source

All Articles