I am using System.Net.Http.HttpClient directly in the Xamarin.Forms PCL. While it runs absolutely fine on Windows Phone, on Android it throws an unhandled exception on the GetAsync line.
Is there something platform specific I'm missing?
var client = new HttpClient();
var response = await client.GetAsync(Constants.ProjectsUri); // this breaks
In the Android Build Settings, set HttpClient Implementation
to use AndroidClientHandler
.
The AndroidClientHandler class was introduced in Xamarin.Android 6.1 to provide TLS 1.2 support to Xamarin.Android applications. This class uses the native java.net.URLConnection for all HTTP connections, allowing an HttpClient instance to use any network and encryption protocols available to Android.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.