Bug 57108 - 2.3.5.239-pre3 NullReferenceException at Xamarin.Forms.Platform.Android.Platform.SetActionBarTextColor
Summary: 2.3.5.239-pre3 NullReferenceException at Xamarin.Forms.Platform.Android.Platf...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.5
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
: 56412 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-06-02 14:38 UTC by philip
Modified: 2017-06-29 09:49 UTC (History)
10 users (show)

Tags: ac android formsapplicationactivity nre crash
Is this bug a regression?: Yes
Last known good build: 2.3.4.247


Attachments
android app with null exception at SetActionBarTextColor (43.01 KB, application/x-zip-compressed)
2017-06-02 14:38 UTC, philip
Details
Attached are the logs generated during defect verification (1.85 KB, application/x-zip-compressed)
2017-06-29 09:47 UTC, Saurabh Paunikar
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description philip 2017-06-02 14:38:54 UTC
Created attachment 22655 [details]
android app with null exception at SetActionBarTextColor

Upgrading from 2.3.4.246 to 2.3.5.239-pre3 causes the following exception at application load.  This is with Android 6.

I am attaching a sample project that shows this.

06-02 14:30:53.590 I/MonoDroid( 5052): UNHANDLED EXCEPTION:
06-02 14:30:53.642 I/MonoDroid( 5052): System.NullReferenceException: Object reference not set to an instance of an object.
06-02 14:30:53.642 I/MonoDroid( 5052):   at Xamarin.Forms.Platform.Android.Platform.SetActionBarTextColor () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\LabelRenderer.cs:74 
06-02 14:30:53.642 I/MonoDroid( 5052):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarTextColor () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\EntryRenderer.cs:86 
06-02 14:30:53.642 I/MonoDroid( 5052):   at Xamarin.Forms.Platform.Android.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:27 
06-02 14:30:53.642 I/MonoDroid( 5052):   at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:577 
06-02 14:30:53.642 I/MonoDroid( 5052):   at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0 
06-02 14:30:53.642 I/MonoDroid( 5052):   at (wrapper dynamic-method) System.Object:9ef35940-7c5a-48dd-9bae-7d8403c32ad4 (intptr,intptr,bool,int,int,int,int)
Comment 1 Jimmy [MSFT] 2017-06-02 18:39:16 UTC
I can confirm this crash with the 2.3.5 builds. 

This is a result of using the Holo theme on Lollipop and higher. There are actually two different issues that can occur:

1. If using a theme without an ActionBar, then you will get an NRE.
2. If the theme has an ActionBar, then an InvalidCastException is thrown because the theme does not have a Toolbar

The changes that are causing this were introduced in 2.3.5 so this is a regression from 2.3.4.
Comment 2 Jimmy [MSFT] 2017-06-02 18:43:31 UTC
See PR: https://github.com/xamarin/Xamarin.Forms/pull/961
Comment 3 Jimmy [MSFT] 2017-06-21 17:47:21 UTC
*** Bug 56412 has been marked as a duplicate of this bug. ***
Comment 4 Rui Marinho 2017-06-22 18:52:50 UTC
Should be fixed on 2.3.5 stable
Comment 5 Saurabh Paunikar 2017-06-29 09:47:49 UTC
Created attachment 23202 [details]
Attached are the logs generated during defect verification