App crashed on clicking entry fielding in android oreo 8.1

kefikefi Member ✭✭

[0:] [Info][MenuSelectionPageViewModel] Closed
04-11 10:36:41.568 D/[email protected]MainActivity: ViewPostIme pointer 0
04-11 10:36:41.604 D/[email protected]MainActivity: ViewPostIme pointer 1
04-11 10:36:41.607 D/AbsListView( 3594): onTouchUp() mTouchMode : 0
04-11 10:36:41.764 W/zygote64( 3594): JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.EntryRenderer
04-11 10:36:42.617 D/[email protected]MainActivity: ViewPostIme pointer 0
04-11 10:36:42.660 D/[email protected]MainActivity: ViewPostIme pointer 1
04-11 10:36:42.714 V/InputMethodManager( 3594): Starting input: [email protected] nm : Kefi.Kefi [email protected]
04-11 10:36:42.714 D/InputMethodManager( 3594): startInputInner - Id : 0
04-11 10:36:42.715 I/InputMethodManager( 3594): startInputInner - mService.startInputOrWindowGainedFocus
04-11 10:36:42.716 D/InputTransport( 3594): Input channel constructed: fd=95
04-11 10:36:42.717 D/InputTransport( 3594): Input channel destroyed: fd=90
04-11 10:36:42.717 D/InputMethodManager( 3594): SSI - flag : 0 Pid : 3594 view : Kefi.Kefi
04-11 10:36:42.756 D/InputTransport( 3594): Input channel constructed: fd=99
04-11 10:36:42.757 D/[email protected]PopupWindow:9656c3a: setView = android.widget.PopupWindow$PopupDecorView{c2e1206 V.E...... ......I. 0,0-0,0} TM=true MM=false
04-11 10:36:42.776 D/[email protected]PopupWindow:9656c3a: dispatchAttachedToWindow
04-11 10:36:42.799 V/Surface ( 3594): sf_framedrop debug : 0x4f4c, game : false, logging : 0
04-11 10:36:42.800 D/[email protected]PopupWindow:9656c3a: Relayout returned: old=[0,0][0,0] new=[356,756][436,851] result=0x7 surface={valid=true 528423280640} changed=true
04-11 10:36:42.803 D/mali_winsys( 3594): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000, [80x95]-format:1
04-11 10:36:42.803 D/OpenGLRenderer( 3594): eglCreateWindowSurface = 0x7b0876d580, 0x7b087b6010
04-11 10:36:42.822 D/[email protected]PopupWindow:9656c3a: MSG_RESIZED_REPORT: frame=Rect(356, 756 - 436, 851) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
04-11 10:36:42.965 D/[email protected]MainActivity: MSG_RESIZED: frame=Rect(0, 0 - 1080, 2340) ci=Rect(0, 85 - 0, 126) vi=Rect(0, 85 - 0, 939) or=1
Unhandled Exception:

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

Tagged:

Answers

  • yelinzhyelinzh Member, Xamarin Team Xamurai

    Instance of an object causes the problem.Please post the code of EntryRenderer and xaml. It'll be helpful to reproduce the issue and find a solution.

  • kefikefi Member ✭✭

    My xaml Code is :

    <?xml version="1.0" encoding="utf-8" ?>


    <Grid.RowDefinitions>









    </Grid.RowDefinitions>

    <UserControl:BackButton.GestureRecognizers>

    </UserControl:BackButton.GestureRecognizers>

    And my ViewModel.cs code is :

    using Acr.UserDialogs;
    using Kefi.Helper;
    using Kefi.Interfaces;
    using Kefi.Models.API.RequestModel;
    using Plugin.Connectivity;
    using Prism.Commands;
    using Prism.Mvvm;
    using Prism.Navigation;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Xamarin.Forms;

    namespace Kefi.ViewModels
    {
    public class LANIPScreenViewModel : BindableBase
    {
    private INavigationService _navigationService;
    private string _labelLANIP ;
    private string _labelSubnetMask;
    private IWebApiCallService _webApiCallService;
    private string _netmask;
    public string LabelLANIP
    {
    get {
    _labelLANIP = LocalSettings.Lan_ip.ToString();
    return _labelLANIP;

            }
            set { _labelLANIP  = value; }
        }
        public string Netmask
        {
            get {
                _netmask = LocalSettings.Netmask.ToString();
                return _netmask;
            }
            set { _netmask = value; }
        }
    
        public LANIPScreenViewModel(INavigationService navigationService, IWebApiCallService webApiCallService)
        {
            _navigationService = navigationService;
            _webApiCallService = webApiCallService;
    
            //Lanipaddress();
        }
        //private async Task Lanipaddress()
        //{
    
    
        //}
        public DelegateCommand BackButtonCommand => new DelegateCommand(() =>
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                await _navigationService.NavigateAsync("AdvancedScreen");
            });
        });
        public DelegateCommand SaveCommand => new DelegateCommand(() =>
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                try
                {
                    if (CrossConnectivity.Current.IsConnected)
                    {
                        var data = App.Current.Properties["DeviceId"].ToString();
                        var data1 = _labelLANIP;
                        var data2 = _netmask;
                        LanIpRequestModel lanIpdata = new LanIpRequestModel
                        {
                            kefi_device_id = App.Current.Properties["DeviceId"].ToString(),
                            lan_ip = _labelLANIP,
                            subnet = _netmask
                        };
                        UserDialogs.Instance.ShowLoading();
                        var result = await _webApiCallService.LANIP(lanIpdata);
                        if (result.statusCode == 200)
                        {
                            LocalSettings.Lan_ip= _labelLANIP;
                            UserDialogs.Instance.HideLoading();
                            DependencyService.Get<Toasts>().Show("Data changed successfully.");
                        }
                        else if (result.statusCode == 404)
                        {
                            UserDialogs.Instance.HideLoading();
                            DependencyService.Get<Toasts>().Show("Couldn't complete request at this moment. Your device seems to be offline.");
                        }
                        else
                        {
                            UserDialogs.Instance.HideLoading();
                            DependencyService.Get<Toasts>().Show("Something went wrong!.Please try again");
                        }
                    }
                    else
                    {
                        UserDialogs.Instance.HideLoading();
                        DependencyService.Get<Toasts>().Show("Couldn't connect to internet.Please try again");
                    }
                }
                catch
                {
                    UserDialogs.Instance.HideLoading();
                    DependencyService.Get<Toasts>().Show("Internal Server Error.Please try again");
                }
            });
        });
    }
    

    }

    And my xaml.cs code is :

    using Xamarin.Forms;

    namespace Kefi.Views.Advanced
    {
    public partial class LANIPScreen : ContentPage
    {
    public LANIPScreen()
    {
    InitializeComponent();
    }
    protected override bool OnBackButtonPressed()
    {
    Device.BeginInvokeOnMainThread(async () =>
    {
    await Navigation.PushModalAsync(new AdvancedScreen(), true);
    });
    return true;
    }
    }
    }

  • kefikefi Member ✭✭
    edited April 11

    "'''''''''''''''''''''''''''''''''''''''''''''''''''<?xml version="1.0" encoding="utf-8" ?>

        <Entry Text="{Binding Netmask}" Grid.Row="5" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"  TextColor="Black" FontSize="Medium" FontAttributes="None" Margin="10,0,0,0"/>
    

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  • kefikefi Member ✭✭
    edited April 11

    Entry field:

    ""

  • yelinzhyelinzh Member, Xamarin Team Xamurai

    Initialize the model class and set the BindingContext. As the following code shows.
    page.xaml.cs

    namespace App6
    {
        [XamlCompilation(XamlCompilationOptions.Compile)]
        public partial class Page2 : ContentPage
        {
            public Page2 ()
            {
                InitializeComponent ();
                Entry_Model entry_Model = new Entry_Model { entry_content = "entry_binding problem" };
                entry.BindingContext = entry_Model;
            }
        }
    
        public class Entry_Model {
            public string entry_content { get; set; }
        }
    }
    

    page.xaml

    <StackLayout>
        <Entry x:Name="entry" Text="{Binding entry_content}"/>
    </StackLayout>
    

    Check the link: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/basic-bindings

  • kefikefi Member ✭✭

    I am using xamarin prism and these problem occur only in android oreo 8.1.

  • yelinzhyelinzh Member, Xamarin Team Xamurai

    Would you mind sharing a basic demo? Or you can find which line of code caused the crash through breakpoint debugging.

  • kefikefi Member ✭✭

    Actually when we open the page then page is open properly but when we click on entry field then app is Instantly crashed even it not comes to get set point of the entry field.and we add the breakpoints in all line but breakpoint is not come to even single line after clicking on the field.

Sign In or Register to comment.