Updating Xamarin to the latest stable seems to have broken Android custom styles for XF

AdrianKnightAdrianKnight USMember ✭✭✭✭

VS popped a message on me about an update to Xamarin and so I updated it to the latest stable. Xamarin Studio seems to be on par with VS. I noticed if you create a new project, UWP, Windows, and WP81 solutions will be added instead of silverlight. Good. However, Android seems to be broken. If I add styles.xml and set the application to use it on either activity or application level, I get the following error:

01-31 07:07:08.315 I/MonoDroid(26231): UNHANDLED EXCEPTION:
01-31 07:07:08.315 I/MonoDroid(26231): System.NullReferenceException: Object reference not set to an instance of an object
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarHomeAsUp (Android.App.ActionBar actionBar) [0x0001d] in <filename unknown>:0 
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.Platform.HideActionBar () [0x0000d] in <filename unknown>:0 
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () [0x000a0] in <filename unknown>:0 
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000bd] in <filename unknown>:0 
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x000b7] in <filename unknown>:0 
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () [0x0000c] in <filename unknown>:0 
01-31 07:07:08.315 I/MonoDroid(26231):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application application) [0x0002d] in <filename unknown>:0 
01-31 07:07:08.325 I/MonoDroid(26231):   at App23.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00020] in C:\Users\xyz\Documents\Visual Studio 2015\Projects\App23\App23\App23.Droid\MainActivity.cs:24 
01-31 07:07:08.325 I/MonoDroid(26231):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/2692/e98e9627/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2857 
01-31 07:07:08.325 I/MonoDroid(26231):   at (wrapper dynamic-method) System.Object:0d4ea3af-d627-4c79-af83-fd09d236a7f1 (intptr,intptr,intptr)
01-31 07:07:08.335 W/art     (26231): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable

I have the below settings:
Compile using Android version: Use Latest Platform (Android 6.0 Marshmallow)
Minimum Android to target; Android 4.0.3 (API Level 15)
Target Android version: Use Compile using SDK version

Error is thrown at LoadApplication(new App()); in MainActivity.cs

This is driving me nuts. There seems to be a bug with regards to hiding/showing the action bar. I kept changing XF Nuget version to different stable ones with no luck. Anyone knows how to fix this?

Answers

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Here's my MainActivity.cs

       [Activity(Label = "App23", Icon = "@drawable/icon", Theme="@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
        public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
        {
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
    
                global::Xamarin.Forms.Forms.Init(this, bundle);     
                LoadApplication(new App());
            }
        }
    

    Here's styles.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
      <style name="MyTheme" parent="android:Theme">
      </style>
    </resources>
    

    Right now, it's empty, but it doesn't really matter what I put in there.

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    I just opened a bug. https://bugzilla.xamarin.com/show_bug.cgi?id=38227

    I verified Xamarin.Android works fine. In the interim, please suggest a solution if you think this is an error on my part.

Sign In or Register to comment.