New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Shell] Android crashes when no icon override provided for back button #5211

Open
davidortinau opened this Issue Feb 12, 2019 · 0 comments

Comments

1 participant
@davidortinau
Copy link
Contributor

davidortinau commented Feb 12, 2019

Description

iOS runs this fine, but Android seems to demand an icon.

https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Renderers/ShellToolbarTracker.cs#L240

Steps to Reproduce

Run this, or at least the BackButtonBehavior part. I only want text, no icon. This is ok on iOS, but Android crashes.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             x:Class="VisualChallenge.VisualChallengePage"
             Shell.NavBarIsVisible="true"
             Title="Edit Request"
             >
    
    <Shell.BackButtonBehavior>
        <BackButtonBehavior TextOverride="Cancel"></BackButtonBehavior>
    </Shell.BackButtonBehavior>
    
    <ContentPage.Resources>
        <StyleSheet>
            <![CDATA[
                .EntryLabel {
                    color: #999999;
                    font-size: 10;
                    font-family: Raleway Bold;
                }
            
                ^Entry, ^Editor {
                    color: #999999;
                    font-size: 18;
                    font-family: Raleway Regular;
                    background-color: transparent;
                    height: 24;
                }
                
                ^Picker {
                    color: #999999;
                    font-size: 18;
                    font-family: Raleway Regular;
                }
                
                .actionButton {
                    background-color: #f05123;
                    color: white;
                    font-family: Raleway Bold;
                }
            ]]>
        </StyleSheet>
    </ContentPage.Resources>
    
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Save"/>
    </ContentPage.ToolbarItems>
    
    <ScrollView>
        <StackLayout Margin="21,30">

            <Label Text="REQUEST TITLE" class="EntryLabel" />
            <Entry Placeholder="Title" />
            
            <Label Text="PRIORITY" class="EntryLabel" />
            <Picker />
            
            <Label class="EntryLabel">
                <Label.FormattedText>
                    <FormattedString>
                        <Span>DETAILS</Span> <Span FontFamily="Raleway Regular" FontSize="10">(OPTIONAL)</Span>
                    </FormattedString>
                </Label.FormattedText>
            </Label>
            <Editor Placeholder="Clean bed, plant, shrubs, trim trees" />
            
            <Label Text="PHOTOS &amp; VIDEOS" class="EntryLabel" />
            
            <Button BorderColor="#999999" 
                    CornerRadius="0" 
                    BorderWidth="1" 
                    BackgroundColor="White"
                    TextColor="Black"
                    ContentLayout="Top, 8"
                    Image="icon_camera" 
                    Text="ADD PHOTO OR VIDEO" 
                    FontFamily="Raleway Bold" 
                    HorizontalOptions="Fill" Padding="40" />

            <Button class="actionButton" Text="CANCEL REQUEST" HeightRequest="46" />

        </StackLayout>
    </ScrollView>
    
</ContentPage>

Expected Behavior

I get a text only button.

Actual Behavior

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.ArgumentNullException: Value cannot be null.
[MonoDroid] Parameter name: obj
[MonoDroid]   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj) [0x00003] in D:\a\1\s\Xamarin.Forms.Core\Registrar.cs:86 
[MonoDroid]   at Xamarin.Forms.Platform.Android.ResourceManager+<GetFormsDrawable>d__16.MoveNext () [0x0002b] in D:\a\1\s\Xamarin.Forms.Platform.Android\ResourceManager.cs:32 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at Xamarin.Forms.Platform.Android.ShellToolbarTracker+<UpdateLeftBarButtonItem>d__36.MoveNext () [0x00047] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellToolbarTracker.cs:240 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
[MonoDroid]   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <a8949430f2ba4ae5a927ceb0a2f16b38>:0 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <a8949430f2ba4ae5a927ceb0a2f16b38>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <a8949430f2ba4ae5a927ceb0a2f16b38>:0 
[MonoDroid]   at (wrapper dynamic-method) System.Object.24(intptr,intptr)
[zygote] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_throw'.
[Mono] Probing 'java_interop_jnienv_throw'.
[Mono] Found as 'java_interop_jnienv_throw'.
[mono] 
[mono] Unhandled Exception:
[mono] System.ArgumentNullException: Value cannot be null.
[mono] Parameter name: obj
[mono]   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj) [0x00003] in D:\a\1\s\Xamarin.Forms.Core\Registrar.cs:86 
[mono]   at Xamarin.Forms.Platform.Android.ResourceManager+<GetFormsDrawable>d__16.MoveNext () [0x0002b] in D:\a\1\s\Xamarin.Forms.Platform.Android\ResourceManager.cs:32 
[mono] --- End of stack trace from previous location where exception was thrown ---
[mono]   at Xamarin.Forms.Platform.Android.ShellToolbarTracker+<UpdateLeftBarButtonItem>d__36.MoveNext () [0x00047] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellToolbarTracker.cs:240 
[mono] --- End of stack trace from previous location where exception was thrown ---
[mono]   at (wrapper dynamic-method) System.Object.24(intptr,intptr)
[mono]   at (wrapper native-to-managed) System.Object.24(intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
[mono-rt] Parameter name: obj
[mono-rt]   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj) [0x00003] in D:\a\1\s\Xamarin.Forms.Core\Registrar.cs:86 
[mono-rt]   at Xamarin.Forms.Platform.Android.ResourceManager+<GetFormsDrawable>d__16.MoveNext () [0x0002b] in D:\a\1\s\Xamarin.Forms.Platform.Android\ResourceManager.cs:32 
[mono-rt] --- End of stack trace from previous location where exception was thrown ---
[mono-rt]   at Xamarin.Forms.Platform.Android.ShellToolbarTracker+<UpdateLeftBarButtonItem>d__36.MoveNext () [0x00047] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellToolbarTracker.cs:240 
[mono-rt] --- End of stack trace from previous location where exception was thrown ---
[mono-rt]   at (wrapper dynamic-method) System.Object.24(intptr,intptr)
[mono-rt]   at (wrapper native-to-managed) System.Object.24(intptr,intptr)

Basic Information

  • Version with issue: 4.0.1 nightly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment