Hi, I'm getting a NullReferenceException at this line:
LoadApplication(new App()); in my main activity.
What I was working on was adding a Compat Theme in order to get this badge plugin working, following this and this blogpost.
[Activity(Label = "ServiceApp.Droid",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : FormsAppCompatActivity {
protected override void OnCreate(Bundle bundle) {
FormsAppCompatActivity.ToolbarResource = Resource.Layout.Toolbar;
FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;
base.OnCreate(bundle);
[...]
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
[...]
}
Resources looking like this:
Resources/values/color.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#FFDD00</color>
<color name="primaryDark">#FFDD00</color>
<color name="primaryLight">#FFECB3</color>
<color name="accent">#9E9E9E</color>
<color name="primaryText">#212121</color>
<color name="secondaryText">#757575</color>
<color name="window_background">#FFFFFF</color>
<color name="icons">#212121</color>
<color name="divider">#BDBDBD</color>
</resources>
Resources/values/styles.xml:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowBackground">@color/window_background</item>
<item name="windowActionModeOverlay">true</item>
</style>
</resources>
Resources/values-v21/styles.xml:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
Also
Resources/layout/Tabbar.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabIndicatorColor="@android:color/white"
app:tabGravity="fill"
app:tabMode="fixed" />
And
Resources/layout/Toolbar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
Am I missing something about the themes? Or is there a way to get more info abot the exception?
I followed it by stepping through the LoadApplication(new App()); and it seemed it crashed on the very last step.
Thanks for your help,
regards, Martin