Bug 30091 - Issue with V7 AppCompat Toolbar
Summary: Issue with V7 AppCompat Toolbar
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-05-14 14:51 UTC by Anubhav Ranjan
Modified: 2017-06-19 19:36 UTC (History)
6 users (show)

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

sample to reproduce (27.15 KB, application/octet-stream)
2015-05-27 05:43 UTC, Vincent Gibault

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:

Description Anubhav Ranjan 2015-05-14 14:51:59 UTC
One of our customers is facing issues with V7 AppCompat Toolbar in Android

I am trying to use the new AppCompatDelegate, and I am getting a null pointer exception:

System.Diagnostics.Debugger.Mono_UnhandledException (ex={Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.

--- End of managed exception stack trace ---
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
... 2 more
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarHomeAsUp (Android.App.ActionBar) <IL 0x0001f, 0x000ad>
at Xamarin.Forms.Platform.Android.Platform.HideActionBar () <IL 0x0000d, 0x0005f>
at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () <IL 0x000a8, 0x0033f>
at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page) <IL 0x000c0, 0x003e3>
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page) <IL 0x000be, 0x00413>
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () <IL 0x0000c, 0x00047>
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application) <IL 0x0002e, 0x00153>
at AppCompat.Droid.MainActivity.OnCreate (Android.OS.Bundle) [0x00064] in /Users/Wes/Projects/AppCompat/Droid/MainActivity.cs:30
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2707
at (wrapper dynamic-method) object.dff9271f-027b-4444-9924-202c6ad3e45c (intptr,intptr,intptr) <IL 0x00017, 0x0002b>

at md5586d58fe00b6a03a6f64d0808f2689f0.MainActivity.n_onCreate(Native Method)
at md5586d58fe00b6a03a6f64d0808f2689f0.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
... 5 more
}) in

I have tried setting the Action bar as noted in the comments of the project but when I do that I get a class not found exception.

How can I use the new Toolbar with a Xamarin forms application. The null pointer exception doesn’t make any sense because unless I set the actionbar it shouldn’t try to update it, and I have no navigation pages. Shouldn’t there be a null check in the Xamarin Forms dll that checks if the action bar is null before trying to update it?

#Version info:
Xamarin Studio
Version 5.9 (build 431)
Installation UUID: bd8184ca-ca0d-40bf-a419-fafa6cd5924b
Mono 4.0.0 ((detached/d136b79)
GTK+ 2.24.23 (Raleigh theme)

Package version: 400000143

Version: (Enterprise Edition)
Android SDK: /Users/Wes/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
Java SDK: /usr
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

Xamarin Android Player
Version: Unknown version
Location: /Applications/Xamarin Android Player.app

Apple Developer Tools
Xcode 6.2 (6776)
Build 6C131e

Version: (Enterprise Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

Not Installed

Build Information
Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

Operating System
Mac OS X 10.10.2
Darwin MACs-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0
Mon Dec 22 23:10:38 PST 2014
root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
Comment 2 Vincent Gibault 2015-05-27 05:43:14 UTC
Created attachment 11354 [details]
sample to reproduce

We have the same problem, I joined a sample to reproduce this problem.

Comment 3 Cody Beyer (MSFT) 2015-05-27 13:06:37 UTC
Confirmed with provided samples
Comment 4 adrianknight89 2016-11-28 06:16:10 UTC
I don't see this exception in 2.3.4-pre1.
Comment 5 Jason Smith [MSFT] 2017-06-19 19:36:20 UTC
I also can no longer reproduce the issue in latest X.F.