MvvmCross / MvvmCross-AndroidSupport

Android support library packages for MvvmCross: The .NET MVVM framework for cross-platform solutions.
http://mvvmcross.com
15 stars 0 forks source link

MvxRecyclerView NullReferenceException when calling constructor #288

Closed instriker closed 8 years ago

instriker commented 8 years ago

Steps to reproduce

  1. Setup a new project using the MvxRecyclerView
  2. Start in Debug mode
  3. Try to display the MvxRecyclerView

    Actual behavior

NullReferenceException is thrown:

"System.NullReferenceException: Object reference not set to an instance of an object.
at MvvmCross.Droid.Support.V7.RecyclerView.AttributeHelpers.MvxRecyclerViewAttributeExtensions.TryInitializeBindingResourcePaths () [0x00047] in <filename unknown>:0 
at MvvmCross.Droid.Support.V7.RecyclerView.AttributeHelpers.MvxRecyclerViewAttributeExtensions.ReadRecyclerViewItemTemplateSelectorClassName (Android.Content.Context context, IAttributeSet attrs) [0x00000] in <filename unknown>:0 
at MvvmCross.Droid.Support.V7.RecyclerView.AttributeHelpers.MvxRecyclerViewAttributeExtensions.BuildItemTemplateSelector (Android.Content.Context context, IAttributeSet attrs) [0x00000] in <filename unknown>:0 
at MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView..ctor (Android.Content.Context context, IAttributeSet attrs, Int32 defStyle, IMvxRecyclerAdapter adapter) [0x00022] in <filename unknown>:0 

Actual behavior cause

In MvvmCross.Droid.Support.V7.RecyclerView project, in the method TryInitializeBindingResourcePaths of the class MvvmCross.Droid.Support.V7.RecyclerView.AttributeHelpers.MvxRecyclerViewAttributeExtensions, there is some reflection executed at runtime : "MvxRecyclerViewItemTemplateSelector = (int) styleableType.GetField("MvxRecyclerView_MvxItemTemplateSelector").GetValue(null);"

In the commit dd8f78154f2001af917303a6d4df6e00117ed2ce, the file MvxRecyclerViewBindingAttributes.xml has been modified so the generated resource MvxRecyclerView_MvxItemTemplateSelector do not exists anymore. Instead, we have MvxRecyclerView_MvxTemplateSelector that is generated.

Configuration

package MvvmCross.Droid.Support.V7.RecyclerView Version: 4.1.7

kjeremy commented 8 years ago

Use the latest MvvmCross packages.

instriker commented 8 years ago

Totally missed it's been fixed since. Thank you!