locked
Updating to 1.5.1 and using AppCompat - Breaks Android LP & M RRS feed

  • Question

  • User169959 posted

    Hi,

    I just updated our android application to 1.5.1 and using AppCompatV7 using this article as a reference. The runs on KitKat but breaks when launching on Lollipop or Marshmallow.

    The stack trace as captured by Raygun,

    Message: [NullReferenceException: Object reference not set to an instance of an object]

    SoniaStudents.Droid.MainActivity.OnCreate(Android.OS.Bundle) in C:\TFS\Cloud\Sonia\Dev\16Q1\Mobile\SoniaStudents\Droid\MainActivity.cs:35

    at Android.Support.V4.App.FragmentActivity.nOnCreateLandroidosBundle_ (intptr,intptr,intptr)

    at (wrapper dynamic-method) object.3af5cf3c-3b4d-459f-be94-ace78520353d (intptr,intptr,intptr)

    Any help would be appreciated.

    Thanks, Daniel.

    Wednesday, October 28, 2015 10:27 AM

Answers

  • User352 posted

    What is on line 35 of MainActivity.cs?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, October 28, 2015 10:38 AM
  • User352 posted

    AppCompat buttons dont support all those properties unfortuantely. You might want to manually export a Renderer for your key buttons that use the old ButtonRenderer

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, October 29, 2015 3:28 AM

All replies

  • User352 posted

    What is on line 35 of MainActivity.cs?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, October 28, 2015 10:38 AM
  • User169959 posted

    Turns out line 35 was the problem (obviously I had a case of blinker vision),

    if ((int)Android.OS.Build.VERSION.SdkInt >= 21) { ActionBar.SetIcon ( new ColorDrawable (Resources.GetColor (Android.Resource.Color.Transparent))); }

    Additionally, I've encountered another issue it seems some of our XAML styles are being ignored when using AppCompat (on all versions of Android). I've attached a screenshot that shows the difference with/without AppCompat and the XAML styles used to generate the control are below.

        <ResourceDictionary>
            <Style x:Key="KeyButtonStyle" TargetType="Button">
                <Setter Property="TextColor" Value="#2d914f"/>
                <Setter Property="BorderRadius" Value="0"/>
                <Setter Property="BackgroundColor" Value="#CCFFFFFF"/>
                <Setter Property="BorderColor" Value="#802d914f"/>
                <Setter Property="BorderWidth" Value="0.5"/>
                <Setter Property="FontSize" Value="Large"/>
            </Style>
            <Style x:Key="CircleButtonStyle" TargetType="Button">
                <Setter Property="WidthRequest" Value="24"/>
                <Setter Property="HeightRequest" Value="24"/>
                <Setter Property="BorderWidth" Value="1"/>
                <Setter Property="BorderRadius" Value="12"/>
                <Setter Property="BorderColor" Value="#BFFFFFFF"/>
                <Setter Property="BackgroundColor" Value="Transparent"/>
                <Setter Property="IsEnabled" Value="false"/>
            </Style>
        </ResourceDictionary>
    
    Wednesday, October 28, 2015 11:16 PM
  • User352 posted

    AppCompat buttons dont support all those properties unfortuantely. You might want to manually export a Renderer for your key buttons that use the old ButtonRenderer

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, October 29, 2015 3:28 AM