title: async/await method crash web services response in Android but same code work successfully in Window Phone and iOS apps in xamarin Native Application
body: <p><strong>async/await method crash web services response in Android but same code work successfully in Window Phone and iOS apps in xamarin Native Application.</strong></p>
  
  <p><strong>Xamarin Native Application (PCL)</strong></p>
  
  <p>I have created a Native application using portable Class library.</p>
  
  <p>I request to REST API that gives the following response.</p>
  
  <pre><code>{
  code: 200,
  status: "ok",
  message: "hello"
  }
  </code></pre>
  
  <p>my Portable class library code in xamarin.forms is</p>
  
  <p><strong>test.xaml.cs</strong></p>
  
  <pre><code>public class jsonResponseClass
  {
          public string code { get; set; }
          public string status { get; set; }
          public string message { get; set; }
  }
  public partial class test : ContentPage
  {
          public async void getDatas()
          {
              var cl = new HttpClient();
              var result = await cl.GetStringAsync("http://192.168.1.125/apps/jara/web/api/user/test");
              jsonResponseClass des = JsonConvert.DeserializeObject&lt;jsonResponseClass&gt;(result);
              lbl1.Text = des.code + " " + des.status + " " + des.message;
          }
          public test()
          {
              InitializeComponent();
              getDatas();
          }
  }
  </code></pre>
  
  <p><strong>Main file in Portable class library (PCL)</strong></p>
  
  <p><strong>App.cs</strong></p>
  
  <pre><code>namespace NativeAppsWithWCF
  {
      public class App : Application
      {
          public App()
          {
              MainPage = new test();
          }
          protected override void OnStart()
          {
              // Handle when your app starts
          }
  
          protected override void OnSleep()
          {
              // Handle when your app sleeps
          }
  
          protected override void OnResume()
          {
              // Handle when your app resumes
          }
      }
  }
  </code></pre>
  
  <p>my Visual studio solution explorer</p>
  
  <p><a href="https://i.stack.imgur.com/hNR0i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hNR0i.png" alt="enter image description here"></a></p>
  
  <p>Using this above code I can successfully show output in iOS and Window Phone Apps.</p>
  
  <p>But when I Run Android apps then crash the apps and not show output.</p>
  
  <p>When I debug Android program then cursor remove after this line.</p>
  
  <pre><code>var result = await
  cl.GetStringAsync("http://192.168.1.125/apps/jara/web/api/user/test");
  </code></pre>
  
  <p>After this line stop the execution of program.</p>
  
  <p><strong>Which means it won't wait for the method to finish executing</strong></p>
  
  <p>See the screen after got error..</p>
  
  <p><a href="https://i.stack.imgur.com/YChyF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YChyF.png" alt="enter image description here"></a></p>
  
  <p>How to prevent this error?</p>