title: Android 4.x - 5.x: WebException when using Appcenter?
body: <p>Testing our app on a variety of different devices and Android versions ranging from Android 4.4 – KitKat (API Level 19) to Android 10 - Q (API Level 29). The app should support a minimum of 4.4 but appcenter tests are showing it is working at a minimum of Android 6.0 - Marshmallow (API Level 23). Tests on API Levels 19-22 (and even some other devices) fail with the resulting POST failed exception.</p>
  
  <p>The error logs, 'Test Failures' and 'Device logs', aren't terribly helpful as neither detail the origin of the two errors produced.</p>
  
  <p><code>SetUp : System.Net.WebException : POST Failed</code></p>
  
  <p>and</p>
  
  <pre><code>Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.util.Locale.getLanguage()' on a null object reference
  </code></pre>
  
  <p>The first is what shows up in 'Test Failures' and the latter appears multiple times in the 'Device logs' but neither in both. Unsure how the two correlate as they would seem unrelated. </p>
  
  <p>Attempted to handle the post failed exception via <a href="https://stackoverflow.com/questions/48450290/https-post-failure">this</a> solution. It suggests the error results from a given device not being able to trust a self-signed cert. However implementing that solution doesn't mitigate the exception.</p>
  
  <p>Verified via console outs that the VS app center device itself has internet and it's reporting a reachable WiFi connection</p>
  
  <pre><code>I/mono-stdout(26664): *** ENTER ReachabilityCheck ***
  I/mono-stdout(26664): ConnectionState?: WiFi
  I/mono-stdout(26664): Reachable?: True
  I/mono-stdout(26664): *** exit ReachabilityCheck ***
  </code></pre>
  
  <p>Logs below. No real clarity as to what is causing there error. Used printouts to check every class instantiation and method call upon app start-up and all enter and exit without error.</p>
  
  <p>How to best go about addressing these exceptions and determining their origin? Toughest part about this process is the app works perfectly well on our testing device, an Galaxy S9+, but lost as to how to debug locally when we can't reproduce. </p>
  
  <p>Test Failure log</p>
  
  <pre><code>SetUp : System.Net.WebException : POST Failed  
      at Xamarin.UITest.Shared.Http.HttpClient.HandleHttpError(System.String method, System.Net.Http.HttpResponseMessage response, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy) [0x00052] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Shared.Http.HttpClient.SendData(System.String endpoint, System.String method, System.Net.Http.HttpContent content, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy, System.Nullable`1[T] timeOut) [0x00123] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Shared.Http.HttpClient.Post(System.String endpoint, System.String arguments, Xamarin.UITest.Shared.Http.ExceptionPolicy exceptionPolicy, System.Nullable`1[T] timeOut) [0x00014] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Shared.Android.HttpApplicationStarter.Execute(System.String intentJson) [0x00035] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Shared.Android.TestCloudAndroidAppLifeCycle.LaunchApp(Xamarin.UITest.Shared.Android.ApkFile appApkFile, Xamarin.UITest.Shared.Android.ApkFile testServerApkFile, System.Int32 testServerPort) [0x0007d] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Android.AndroidApp..ctor(Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration, Xamarin.UITest.Shared.Execution.IExecutor executor) [0x00198] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Android.AndroidApp..ctor(Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration) [0x00000] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in &lt;2a16c16730a54859bda72c6bc1c728f7&gt;:0   
      at MyXamarinApp.UITests.AppInitializer.StartApp(Xamarin.UITest.Platform platform) [0x0001c] in &lt;dde3e94fab0f4c759900a21505cc71ba&gt;:0   
      at MyXamarinApp.UITests.Tests.BeforeEachTest() [0x00000] in &lt;dde3e94fab0f4c759900a21505cc71ba&gt;:0   
      at(wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod, object, object[], System.Exception&amp;)  
      at System.Reflection.MonoMethod.Invoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in &lt;48b95f3df5804531818f80e28ec60191&gt;:0
  </code></pre>
  
  <p>Device logs</p>
  
  <pre><code>I/MonoDroid(18204): UNHANDLED EXCEPTION:
  I/MonoDroid(18204): Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.util.Locale.getLanguage()' on a null object reference
  I/MonoDroid(18204):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in &lt;5bb7aef66ad04ab6a7aebddf719db2c9&gt;:0 
  I/MonoDroid(18204):   at Java.Interop.JniPeerMembers+JniInstanceMethods.FinishCreateInstance (System.String constructorSignature, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0004f] in &lt;5bb7aef66ad04ab6a7aebddf719db2c9&gt;:0 
  I/MonoDroid(18204):   at Android.Support.V7.Widget.AppCompatButton..ctor (Android.Content.Context context) [0x0007a] in &lt;f36899d7138d4405bc94ab104323224d&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer.CreateNativeControl () [0x00006] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00017] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000cb] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c0] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00142] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e8] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c0] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00142] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e8] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c0] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00142] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e8] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager, Android.Content.Context context) [0x00031] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x0001b] in &lt;417fcf321d224e098a7d0491301d2236&gt;:0 
  I/MonoDroid(18204):   at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00020] in &lt;1cf8aa575c3e489899028adaf44662eb&gt;:0 
  I/MonoDroid(18204):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.88(intptr,intptr,intptr,intptr,intptr)
  I/MonoDroid(18204):   --- End of managed Java.Lang.NullPointerException stack trace ---
  I/MonoDroid(18204): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.util.Locale.getLanguage()' on a null object reference
  I/MonoDroid(18204):     at java.lang.CaseMapper.toUpperCase(CaseMapper.java:151)
  I/MonoDroid(18204):     at java.lang.String.toUpperCase(String.java:1406)
  I/MonoDroid(18204):     at android.text.method.AllCapsTransformationMethod.getTransformation(AllCapsTransformationMethod.java:43)
  I/MonoDroid(18204):     at android.widget.TextView.setText(TextView.java:4790)
  I/MonoDroid(18204):     at android.widget.TextView.setText(TextView.java:4678)
  I/MonoDroid(18204):     at android.widget.TextView.setText(TextView.java:4653)
  I/MonoDroid(18204):     at android.widget.TextView.setTransformationMethod(TextView.java:2288)
  I/MonoDroid(18204):     at android.widget.TextView.&lt;init&gt;(TextView.java:1763)
  I/MonoDroid(18204):     at android.widget.Button.&lt;init&gt;(Button.java:115)
  I/MonoDroid(18204):     at android.widget.Button.&lt;init&gt;(Button.java:108)
  I/MonoDroid(18204):     at android.support.v7.widget.AppCompatButton.&lt;init&gt;(AppCompatButton.java:71)
  I/MonoDroid(18204):     at android.support.v7.widget.AppCompatButton.&lt;init&gt;(AppCompatButton.java:67)
  I/MonoDroid(18204):     at android.support.v7.widget.AppCompatButton.&lt;init&gt;(AppCompatButton.java:63)
  I/MonoDroid(18204):     at md58432a647068b097f9637064b8985a5e0.FragmentContainer.n_onCreateView(Native Method)
  I/MonoDroid(18204):     at md58432a647068b097f9637064b8985a5e0.FragmentContainer.onCreateView(FragmentContainer.java:33)
  I/MonoDroid(18204):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
  I/MonoDroid(18204):     at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
  I/MonoDroid(18204):     at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
  I/MonoDroid(18204):     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
  I/MonoDroid(18204):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1244)
  I/MonoDroid(18204):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1092)
  I/MonoDroid(18204):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1622)
  I/MonoDroid(18204):     at android.view.View.measure(View.java:18843)
  I/MonoDroid(18204):     at md58432a647068b097f9637064b8985a5e0.CarouselPageRenderer.n_onLayout(Native Method)
  I/MonoDroid(18204):     at md58432a647068b097f9637064b8985a5e0.CarouselPageRenderer.onLayout(CarouselPageRenderer.java:67)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
  I/MonoDroid(18204):     at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.n_onLayout(Native Method)
  I/MonoDroid(18204):     at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.onLayout(PlatformRenderer.java:55)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
  I/MonoDroid(18204):     at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
  I/MonoDroid(18204):     at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
  I/MonoDroid(18204):     at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
  I/MonoDroid(18204):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
  I/MonoDroid(18204):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
  I/MonoDroid(18204):     at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
  I/MonoDroid(18204):     at android.view.View.layout(View.java:16916)
  I/MonoDroid(18204):     at android.view.ViewGroup.layout(ViewGroup.java:5405)
  I/MonoDroid(18204):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2414)
  I/MonoDroid(18204):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2123)
  I/MonoDroid(18204):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1264)
  I/MonoDroid(18204):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6943)
  I/MonoDroid(18204):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
  I/MonoDroid(18204):     at android.view.Choreographer.doCallbacks(Choreographer.java:590)
  I/MonoDroid(18204):     at android.view.Choreographer.doFrame(Choreographer.java:560)
  I/MonoDroid(18204):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
  I/MonoDroid(18204):     at android.os.Handler.handleCallback(Handler.java:739)
  I/MonoDroid(18204):     at android.os.Handler.dispatchMessage(Handler.java:95)
  I/MonoDroid(18204):     at android.os.Looper.loop(Looper.java:145)
  I/MonoDroid(18204):     at android.app.ActivityThread.main(ActivityThread.java:6837)
  I/MonoDroid(18204):     at java.lang.reflect.Method.invoke(Native Method)
  I/MonoDroid(18204):     at java.lang.reflect.Method.invoke(Method.java:372)
  I/MonoDroid(18204):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
  I/MonoDroid(18204):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
  </code></pre>