Azure Devops: Android Forms app using Shell crashes when built by the Azure Pipeline

Note: This issue can be reproduced using the Shell app template.

I'm going to work around this issue by stripping out shells from my app. But am posting this as my search for the error isn't anywhere on the net and I can't believe nobody has run into this before.

I have a new Xamarin Forms app using the new Shell framework that I'm trying to get built by Azure Pipelines and deployed via Visual Studio App Center.

The iOS build is completely fine. And the Android build works running locally and even when locally built and manually uploaded to Visual Studio App Center. But when I build the Android app using Azure Pipelines, the app crashes on startup.

I've deduced that this is an issue with Shell vs Azure Pipelines since this issue even happens when I built a test app from the unmodified shell app template with .NET standard for the shared code.

This is the error logged by LogCat:

08-30 13:22:05.781 25813 25813 E AndroidRuntime: FATAL EXCEPTION: main
08-30 13:22:05.781 25813 25813 E AndroidRuntime: Process: au.com.sfi.testapp, PID: 25813
08-30 13:22:05.781 25813 25813 E AndroidRuntime: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Platform.Android.ShellBottomNavViewAppearanceTracker.SetBackgroundColor (Android.Support.Design.Widget.BottomNavigationView bottomView, Xamarin.Forms.Color color) [0x00080] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Platform.Android.ShellBottomNavViewAppearanceTracker.ResetAppearance (Android.Support.Design.Widget.BottomNavigationView bottomView) [0x00020] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Platform.Android.ShellItemRenderer.ResetAppearance () [0x00000] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Platform.Android.ShellItemRenderer.Xamarin.Forms.IAppearanceObserver.OnAppearanceChanged (Xamarin.Forms.ShellAppearance appearance) [0x00011] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Shell.Xamarin.Forms.IShellController.AddAppearanceObserver (Xamarin.Forms.IAppearanceObserver observer, Xamarin.Forms.Element pivot) [0x0001a] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Platform.Android.ShellItemRenderer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x000bc] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: 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 <12bd1bbeb8ba44d7891a3d564b719f52>:0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at (wrapper dynamic-method) System.Object.44(intptr,intptr,intptr,intptr,intptr)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: --- End of stack trace from previous location where exception was thrown ---
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Android.App.Activity.OnStart () [0x0000a] in <223593b1d75b41baa6db0d4d38d1d7ee>:0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStart () [0x00000] in :0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at Android.App.Activity.n_OnStart (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <223593b1d75b41baa6db0d4d38d1d7ee>:0
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at (wrapper dynamic-method) System.Object.13(intptr,intptr)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at md51558244f76c53b6aeda52c8a337f2c37.FormsAppCompatActivity.n_onStart(Native Method)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at md51558244f76c53b6aeda52c8a337f2c37.FormsAppCompatActivity.onStart(FormsAppCompatActivity.java:120)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1340)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.Activity.performStart(Activity.java:7200)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2918)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6938)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
08-30 13:22:05.781 25813 25813 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
08-30 13:22:05.786 3781 3883 W ActivityManager: crash : au.com.sfi.testapp,0
08-30 13:22:05.786 3781 3883 W ActivityManager: Force finishing activity au.com.sfi.testapp/md5997210f592fb55d53312347a33ae5313.MainActivity

From what i can tell, the null exception is because the bottomtab_tabbar resource can't be found via its ID.

This is the YAML of the build:

steps:

  • task: [email protected]
    displayName: 'Build Application'
    inputs:
    projectFile: '$(System.DefaultWorkingDirectory)/SourceRepo/$(AndroidProjectName)/$(AndroidProjectName).csproj'
    outputDirectory: '$(System.DefaultWorkingDirectory)/Build'
    configuration: Release
    clean: true

The $(AndroidProjectName) variable is so I could switch between test apps on the one pipeline

Since this crash with the test app, I have added a non-shell page that just has a button that switches to the shell app. The app then works but crashes when you try to navigate to the shell app.

Sign In or Register to comment.