Bug 39640 - Suppressing title bar in splash screen crashes app
Summary: Suppressing title bar in splash screen crashes app
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.1.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-15 10:53 UTC by Willem Mali
Modified: 2017-06-16 17:50 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
VS2015 project that reproduces the bug (379.55 KB, application/x-zip-compressed)
2016-03-15 10:56 UTC, Willem Mali
Details
Fixed version using AppCompactActivity (56.56 KB, application/zip)
2016-03-15 16:34 UTC, Rui Marinho
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:
RESOLVED INVALID

Description Willem Mali 2016-03-15 10:53:30 UTC
Recreating the bug goes as follows:

1. Make a new project from the template Blank App (Xamarin.Forms Shared)
2. In MainActivity, set the theme to "@android:style/Theme.NoTitlebar", it'll look like so:

[Activity(Theme = "@android:style/Theme.NoTitleBar", Label = "TestApp", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

3. The app now crashes at startup with the following errors:

Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object

03-15 11:43:18.718 D/Mono    ( 3351): DllImport attempting to load: '/system/lib/liblog.so'.
03-15 11:43:18.718 D/Mono    ( 3351): DllImport loaded library '/system/lib/liblog.so'.
03-15 11:43:18.718 D/Mono    ( 3351): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
03-15 11:43:18.718 D/Mono    ( 3351): Searching for '__android_log_print'.
03-15 11:43:18.718 D/Mono    ( 3351): Probing '__android_log_print'.
03-15 11:43:18.718 D/Mono    ( 3351): Found as '__android_log_print'.
03-15 11:43:18.728 I/MonoDroid( 3351): UNHANDLED EXCEPTION:
03-15 11:43:18.728 I/MonoDroid( 3351): System.NullReferenceException: Object reference not set to an instance of an object
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarHomeAsUp (Android.App.ActionBar actionBar) [0x0001d] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.Platform.HideActionBar () [0x0000d] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () [0x000a0] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000bd] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x000b7] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () [0x0000c] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application application) [0x0002d] in <filename unknown>:0 
03-15 11:43:18.728 I/MonoDroid( 3351):   at TestApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00011] in c:\users\admiral rodcocker\documents\visual studio 2015\Projects\TestApp\TestApp\TestApp.Droid\MainActivity.cs:20 
03-15 11:43:18.728 I/MonoDroid( 3351):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/2970/46c3f7e0/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2857 
03-15 11:43:18.728 I/MonoDroid( 3351):   at (wrapper dynamic-method) System.Object:deb7ccca-3e5e-4072-90d1-b64cc2532090 (intptr,intptr,intptr)
03-15 11:43:18.738 W/art     ( 3351): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
An unhandled exception occured.

03-15 11:43:19.388 E/mono    ( 3351): 
03-15 11:43:19.388 E/mono    ( 3351): Unhandled Exception:
03-15 11:43:19.388 E/mono    ( 3351): System.NullReferenceException: Object reference not set to an instance of an object
03-15 11:43:19.388 E/mono    ( 3351):   at (wrapper dynamic-method) System.Object:deb7ccca-3e5e-4072-90d1-b64cc2532090 (intptr,intptr,intptr)
03-15 11:43:19.388 E/mono    ( 3351):   at (wrapper native-to-managed) System.Object:deb7ccca-3e5e-4072-90d1-b64cc2532090 (intptr,intptr,intptr)
03-15 11:43:19.388 E/mono-rt ( 3351): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
03-15 11:43:19.388 E/mono-rt ( 3351):   at (wrapper dynamic-method) System.Object:deb7ccca-3e5e-4072-90d1-b64cc2532090 (intptr,intptr,intptr)
03-15 11:43:19.388 E/mono-rt ( 3351):   at (wrapper native-to-managed) System.Object:deb7ccca-3e5e-4072-90d1-b64cc2532090 (intptr,intptr,intptr)
referenceTable GDEF length=778 1
referenceTable GSUB length=6388 1
referenceTable GPOS length=66796 1


How do I remove the title bar without triggering this bug? The title bar in the splash screen is ass-ugly.
Comment 1 Willem Mali 2016-03-15 10:56:22 UTC
Created attachment 15405 [details]
VS2015 project that reproduces the bug

You'll have to restore the Xamarin NuGet packages before being able to build the project.
Comment 2 Willem Mali 2016-03-15 10:59:53 UTC
For reference, here is the documentation you provide on splash screens:

https://developer.xamarin.com/guides/android/user_interface/creating_a_splash_screen/

Following the steps in this tutorial results in the same crash. Perhaps you could add a big warning to the page that it only works for 'pure' Xamarin Android and not for Xamarin Forms, so devs won't waste time on trying to implement it.
Comment 3 Rui Marinho 2016-03-15 16:29:44 UTC
Hi Willem, you can do this, but you should use FormsAppCompatActivity instead of the older FormsAppCompatActivity.

You can provide a theme in your styles.xml that looks like this:

> <style name="MyTheme" parent="MyTheme.Base">
>  </style>
>  <!-- Base theme applied no matter what API -->
>  <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
>  	<item name="windowNoTitle">true</item>
>  </style>

And use in your activity like this:

> Theme="@style/MyTheme"
Comment 4 Rui Marinho 2016-03-15 16:34:00 UTC
Created attachment 15410 [details]
Fixed version using AppCompactActivity
Comment 5 Willem Mali 2016-03-15 17:29:56 UTC
Thanks, but your project gives me the exact same error:


Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object

03-15 18:10:44.301 D/Mono    (28537): DllImport attempting to load: '/system/lib/liblog.so'.
03-15 18:10:44.301 D/Mono    (28537): DllImport loaded library '/system/lib/liblog.so'.
03-15 18:10:44.301 D/Mono    (28537): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
03-15 18:10:44.301 D/Mono    (28537): Searching for '__android_log_print'.
03-15 18:10:44.301 D/Mono    (28537): Probing '__android_log_print'.
03-15 18:10:44.301 D/Mono    (28537): Found as '__android_log_print'.
03-15 18:10:44.311 I/MonoDroid(28537): UNHANDLED EXCEPTION:
03-15 18:10:44.311 I/MonoDroid(28537): System.NullReferenceException: Object reference not set to an instance of an object
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarHomeAsUp (Android.App.ActionBar actionBar) [0x0001d] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.Platform.HideActionBar () [0x0000d] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () [0x000a0] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000bd] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x000b7] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () [0x0000c] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application application) [0x0002d] in <filename unknown>:0 
03-15 18:10:44.311 I/MonoDroid(28537):   at TestApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00011] in C:\Users\Admiral Rodcocker\Downloads\TestApp\TestApp\TestApp.Droid\MainActivity.cs:20 
03-15 18:10:44.311 I/MonoDroid(28537):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/2970/46c3f7e0/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2857 
03-15 18:10:44.311 I/MonoDroid(28537):   at (wrapper dynamic-method) System.Object:d76690f4-92ec-4e95-bc96-086a5446c92e (intptr,intptr,intptr)
03-15 18:10:44.321 W/art     (28537): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
An unhandled exception occured.

03-15 18:10:45.551 E/mono    (28537): 
03-15 18:10:45.551 E/mono    (28537): Unhandled Exception:
03-15 18:10:45.551 E/mono    (28537): System.NullReferenceException: Object reference not set to an instance of an object
03-15 18:10:45.551 E/mono    (28537):   at (wrapper dynamic-method) System.Object:d76690f4-92ec-4e95-bc96-086a5446c92e (intptr,intptr,intptr)
03-15 18:10:45.551 E/mono    (28537):   at (wrapper native-to-managed) System.Object:d76690f4-92ec-4e95-bc96-086a5446c92e (intptr,intptr,intptr)
03-15 18:10:45.551 E/mono-rt (28537): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
03-15 18:10:45.551 E/mono-rt (28537):   at (wrapper dynamic-method) System.Object:d76690f4-92ec-4e95-bc96-086a5446c92e (intptr,intptr,intptr)
03-15 18:10:45.551 E/mono-rt (28537):   at (wrapper native-to-managed) System.Object:d76690f4-92ec-4e95-bc96-086a5446c92e (intptr,intptr,intptr)
referenceTable GDEF length=778 1
referenceTable GSUB length=6388 1
referenceTable GPOS length=66796 1



What's the difference between a "FormsAppCompatActivity" and a "FormsAppCompatActivity"? I just took the latest template and set the theme to one of the default ones provided by the Android platform.

I have already tried making a custom theme with windowNoTitle=true, but that gave the exact same error.
Comment 6 Willem Mali 2016-04-12 14:49:03 UTC
Hello?

This problem still occurs with the latest version of Xamarin.Forms.
Comment 7 Evgeniy Zverev 2016-10-04 17:00:48 UTC
Anybody?? We are still suffering from this problem!
Comment 8 adrianknight89 2016-11-21 06:23:35 UTC
This seems to be happening on 2.3.3.166-pre4 with the attached repro, but I wasn't able to duplicate the issue on latest master.
Comment 9 David Ortinau [MSFT] 2017-06-16 17:50:26 UTC
Confirmed @Ruis guidance works and works fine in 2.3.5.239.