Skip to content
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

Crashing on android #115

Open
1 of 2 tasks
wocar opened this issue Jul 3, 2020 · 2 comments
Open
1 of 2 tasks

Crashing on android #115

wocar opened this issue Jul 3, 2020 · 2 comments

Comments

@wocar
Copy link

wocar commented Jul 3, 2020

Description

Steps to Reproduce

<sv:SettingsView x:Name="SettingsView1" VerticalOptions="CenterAndExpand" HasUnevenRows="true">

               <sv:Section HeaderHeight="100">
                   <sv:TimePickerCell
                       x:Name="TimeCell"
                       
                       Title="Hour" Format="%h:mm tt" Time="{Binding Reminder.Time}" />
                   
                   <sv:PickerCell Title="Day"
                                  x:Name="PickerCell"
                                  SelectionMode="Single"
                                  ItemsSource="{Binding DayList}"
                                  SelectedItem="{Binding Reminder.Day}"
                                  DisplayMember="Name"
                                  KeepSelectedUntilBack="true"
                                  PageTitle="Day" />

               

               
               </sv:Section>
               <sv:Section IsVisible="{Binding ShowDeleteButton}">
                   <sv:ButtonCell
                       Command="{Binding DeleteCommand}" Title="Delete alarm" TitleColor="Red" />
               </sv:Section>

           </sv:SettingsView>

Expected Behavior

To display the settings view

Actual Behavior

App Crashes

I get an exception:

System.NullReferenceException: Object reference not set to an instance of an object.

07-03 18:31:07.545 F/DEBUG   (10796): Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI NewString called with pending exception android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object.
07-03 18:31:07.545 F/DEBUG   (10796):   at MvvmCross.Platforms.Android.Binding.Views.MvxLayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x00006] in D:\a\1\s\MvvmCross\Platforms\Android\Binding\Views\MvxLayoutInflater.cs:123 
07-03 18:31:07.545 F/DEBUG   (10796):   at AiForms.Renderers.Droid.SettingsViewRecyclerAdapter.OnCreateViewHolder (Android.Views.ViewGroup parent, System.Int32 viewType) [0x0003d] in <1e41ed7b2758417684675b42060962c6>:0 
07-03 18:31:07.545 F/DEBUG   (10796):   at AndroidX.RecyclerView.Widget.RecyclerView+Adapter.n_OnCreateViewHolder_Landroid_view_ViewGroup_I (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_parent, System.Int32 viewType) [0x00010] in D:\a\1\s\generated\androidx.recyclerview.recyclerview\obj\Release\monoandroid90\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:470 
07-03 18:31:07.545 F/DEBUG   (10796):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.93(intptr,intptr,intptr,int)
07-03 18:31:07.545 F/DEBUG   (10796):   at androidx.recyclerview.widget.RecyclerView$ViewHolder crc6484fad89fba26ff1d.SettingsViewRecyclerAdapter.n_onCreateViewHolder(android.view.ViewGroup, int) (SettingsViewRecyclerAdapter.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at androidx.recyclerview.widget.RecyclerView$ViewHolder crc6484fad89fba26ff1d.SettingsViewRecyclerAdapter.onCreateViewHolder(android.view.ViewGroup, int) (SettingsViewRecyclerAdapter.java:61)
07-03 18:31:07.545 F/DEBUG   (10796):   at androidx.recyclerview.widget.RecyclerView$ViewHolder androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(android.view.ViewGroup, int) (RecyclerView.java:7078)
07-03 18:31:07.545 F/DEBUG   (10796):   at androidx.recyclerview.widget.RecyclerView$ViewHolder androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(int, boolean, long) (RecyclerView.java:6235)
07-03 18:31:07.545 F/DEBUG   (10796):   at android.view.View androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(int, boolean) (RecyclerView.java:6118)
07-03 18:31:07.545 F/DEBUG   (10796):   at android.view.View androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(int) (RecyclerView.java:6114)
07-03 18:31:07.545 F/DEBUG   (10796):   at android.view.View androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(androidx.recyclerview.widget.RecyclerView$Recycler) (LinearLayoutManager.java:2303)
07-03 18:31:07.545 F/DEBUG   (10796):   at void androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.RecyclerView$State, androidx.recyclerview.widget.LinearLayoutManager$LayoutState, androidx.recyclerview.widget.LinearLayoutManager$LayoutChunkResult) (LinearLayoutManager.java:1627)
07-03 18:31:07.545 F/DEBUG   (10796):   at int androidx.recyclerview.widget.LinearLayoutManager.fill(androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.LinearLayoutManager$LayoutState, androidx.recyclerview.widget.RecyclerView$State, boolean) (LinearLayoutManager.java:1587)
07-03 18:31:07.545 F/DEBUG   (10796):   at void androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.RecyclerView$State) (LinearLayoutManager.java:665)
07-03 18:31:07.545 F/DEBUG   (10796):   at void androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2() (RecyclerView.java:4134)
07-03 18:31:07.545 F/DEBUG   (10796):   at void androidx.recyclerview.widget.RecyclerView.dispatchLayout() (RecyclerView.java:3851)
07-03 18:31:07.545 F/DEBUG   (10796):   at void androidx.recyclerview.widget.RecyclerView.onLayout(boolean, int, int, int, int) (RecyclerView.java:4404)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.ViewRenderer_2.n_onLayout(boolean, int, int, int, int) (ViewRenderer_2.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.ViewRenderer_2.onLayout(boolean, int, int, int, int) (ViewRenderer_2.java:47)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(int, int, int, int, int, int) (FormsViewGroup.java:37)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_onLayout(boolean, int, int, int, int) (Platform_DefaultRenderer.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.Platform_DefaultRenderer.onLayout(boolean, int, int, int, int) (Platform_DefaultRenderer.java:72)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(int, int, int, int, int, int) (FormsViewGroup.java:37)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.PageRenderer.n_onLayout(boolean, int, int, int, int) (PageRenderer.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.PageRenderer.onLayout(boolean, int, int, int, int) (PageRenderer.java:72)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(int, int, int, int, int, int) (FormsViewGroup.java:37)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc64720bb2db43a66fe9.NavigationPageRenderer.n_onLayout(boolean, int, int, int, int) (NavigationPageRenderer.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc64720bb2db43a66fe9.NavigationPageRenderer.onLayout(boolean, int, int, int, int) (NavigationPageRenderer.java:65)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(int, int, int, int, int, int) (FormsViewGroup.java:37)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc64720bb2db43a66fe9.Platform_ModalContainer.n_onLayout(boolean, int, int, int, int) (Platform_ModalContainer.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc64720bb2db43a66fe9.Platform_ModalContainer.onLayout(boolean, int, int, int, int) (Platform_ModalContainer.java:53)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.PlatformRenderer.n_onLayout(boolean, int, int, int, int) (PlatformRenderer.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void crc643f46942d9dd1fff9.PlatformRenderer.onLayout(boolean, int, int, int, int) (PlatformRenderer.java:63)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.RelativeLayout.onLayout(boolean, int, int, int, int) (RelativeLayout.java:1103)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.layoutChildren(int, int, int, int, boolean) (FrameLayout.java:332)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.onLayout(boolean, int, int, int, int) (FrameLayout.java:270)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.layoutChildren(int, int, int, int, boolean) (FrameLayout.java:332)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.onLayout(boolean, int, int, int, int) (FrameLayout.java:270)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.layoutChildren(int, int, int, int, boolean) (FrameLayout.java:332)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.onLayout(boolean, int, int, int, int) (FrameLayout.java:270)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.LinearLayout.setChildFrame(android.view.View, int, int, int, int) (LinearLayout.java:1829)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.LinearLayout.layoutVertical(int, int, int, int) (LinearLayout.java:1673)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.LinearLayout.onLayout(boolean, int, int, int, int) (LinearLayout.java:1582)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.layoutChildren(int, int, int, int, boolean) (FrameLayout.java:332)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.widget.FrameLayout.onLayout(boolean, int, int, int, int) (FrameLayout.java:270)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.android.internal.policy.DecorView.onLayout(boolean, int, int, int, int) (DecorView.java:776)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.View.layout(int, int, int, int) (View.java:22826)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewGroup.layout(int, int, int, int) (ViewGroup.java:6316)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewRootImpl.performLayout(android.view.WindowManager$LayoutParams, int, int) (ViewRootImpl.java:3434)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewRootImpl.performTraversals() (ViewRootImpl.java:2907)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewRootImpl.doTraversal() (ViewRootImpl.java:1934)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.ViewRootImpl$TraversalRunnable.run() (ViewRootImpl.java:8127)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.Choreographer$CallbackRecord.run(long) (Choreographer.java:972)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.Choreographer.doCallbacks(int, long) (Choreographer.java:796)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.Choreographer.doFrame(long, int) (Choreographer.java:731)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.view.Choreographer$FrameDisplayEventReceiver.run() (Choreographer.java:957)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:938)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.os.Looper.loop() (Looper.java:223)
07-03 18:31:07.545 F/DEBUG   (10796):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7523)
07-03 18:31:07.545 F/DEBUG   (10796):   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:592)
07-03 18:31:07.545 F/DEBUG   (10796):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:941)

Platforms

  • Android Emulator
  • iOS

Basic Information

  • AiForms.SettingsView 1.2.14-pre

  • Xamarin.Forms 4.7.0.813-pre2

      <PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.1" />
      <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.2.0.1" />
      <PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0" />
      <PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.1" />
      <PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources" Version="1.1.0.1" />
      <PackageReference Include="Xamarin.AndroidX.AppCompat.Resources" Version="1.1.0.1" />
      <PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.1.0.1" />
      <PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
      <PackageReference Include="MvvmCross" Version="6.4.2" />
      <PackageReference Include="MvvmCross.Forms" Version="6.4.2" />
    
      <TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
    

image

@wocar wocar changed the title Not working on android API 30 Crashing on android Jul 3, 2020
@Jakar510
Copy link

Jakar510 commented Sep 3, 2020

This should fix the issue:

Inside of the SettingsView init, capture the context.

[Android.Runtime.Preserve(AllMembers = true)]
public static class SettingsViewInit
{
	internal static Xamarin.Forms.Platform.Android.FormsAppCompatActivity Current { get; set; }

	public static void Init( Xamarin.Forms.Platform.Android.FormsAppCompatActivity activity ) => Current = activity;
}

Change the constructor in SettingsView.Droid.Cells.CellBaseView to use the captured android context:

public CellBaseView( IntPtr javaReference, JniHandleOwnership transfer ) : base(javaReference, transfer) => _Context = SettingsViewInit.Current;

@mattiasskog
Copy link

Any progress o nthe merge of the fix? This also occurs on iOS.
Workaround seems to be not to bind to the SelectedItem.
I can get it to work if I add the SelectedItem in XAML at runtime with hotreload, but if i restart the project it crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants