添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I have a very simple MVVM application using Xamrin Forms and Prism, built from the Prism Xamarin Template.

When I initialize a new ViewModel I am trying to make a call to an API, on UWP this is working without any issues but on Android it is just freezing and not returning any errors or throwing any exceptions.

I have simplified the code down to where the error is happening and tested with a URI that anyone can use.

public async Task InitializeAsync(INavigationParameters parameters)  
            var client = new HttpClient();  
            var response = await client.GetAsync("https://www.google.co.uk").ConfigureAwait(false);  
        catch (Exception ex)  
            System.Diagnostics.Debug.WriteLine(ex.Message);  

I am using the below NuGets

  • Prism.Core v8.0.0.1909
  • Prism.Dryloc.Forms v8.0.0.1909
  • Xamarin.Forms v4.8.0.1687
  • I have set the HttpClient implementation to Android and Native TLS 1.2+ enter image description here

    I have set internet permissions in the Android Manifest

    I have reviewed several other posts that seem similar but have had no joy in fixing the issue, can anyone shed any light on how I can troubleshoot this or get it working?

    After troubleshooting this for a while and banging my head against a brick wall I've finally figured out what was going wrong.

    Nothing!

    Step through on Android wasn't stepping past line 7 below and the screen wasn't redrawing.

    var response = await client.GetAsync("https://www.google.co.uk").ConfigureAwait(false);
    

    When I turned my phone 90 degrees the screen would redraw and I could see that the request had worked.