Почему крашится приложение apk с# xamarin при запуске?

Почему крашится приложение apk с# xamarin при запуске?

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.OS;

namespace QR.Droid
{
    [Activity(Label = "QR", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            ZXing.Net.Mobile.Forms.Android.Platform.Init();
            LoadApplication(new App());
        }
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using System.Collections.Specialized;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace QR
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Work : ContentPage
    {
        string development, otk, id, number, name;
        public Work(string development_, string otk_, string scanResult="")
        {
            InitializeComponent();

            otk = otk_;
            development = development_;

            if (otk != "otk")
            {
                back.IsVisible = false;
            }

            if (scanResult != "")
            {
                string[] scanResult_ = scanResult.Split('\n');

                id = scanResult_[0];
                number = scanResult_[1];
                name = scanResult_[2];

                NumberLabel.Text = "Номер: " + number;
                NameLabel.Text = "Имя: " + name;
            }
        }

        void Scan(object sender, System.EventArgs e)
        {
            Navigation.PushModalAsync(new Camera(development, otk));
        }

        void Server(object sender, System.EventArgs e)
        {
            Button button = sender as Button;
            bool checkOTK = true;

            if (button.ClassId == "back")
            {
                checkOTK = false;
            }

            string add = "";
            if (checkOTK && otk == "otk")
            {
                add = "_otk";
            }

            //CookieContainer cookieContainer = new CookieContainer();
            //string url = "http://code-factory.site/api/give_csrf";
            //HttpClientHandler handler = new HttpClientHandler();
            //HttpClient get = new HttpClient(handler);
            //string csrf = get.GetStringAsync(url).GetAwaiter().GetResult().Split('=')[3];
            //cookieContainer.Add(handler.CookieContainer.GetCookies(new Uri(url)));

            //csrf = csrf.Substring(1, csrf.Length - 2);

            NumberLabel.Text = "";
            NameLabel.Text = "";

            Dictionary<string, string> values = new Dictionary<string, string>
            {
                { "id", id },
                //{ "csrfmiddlewaretoken", csrf }
            };

            FormUrlEncodedContent content = new FormUrlEncodedContent(values);

            string url = "http://code-factory.site/api/"+button.ClassId+add+"/"+development;
            HttpClientHandler handler = new HttpClientHandler();
            HttpClient post = new HttpClient(handler);
            post.PostAsync(url, content);
        }
    }  
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace QR
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Select2 : ContentPage
    {
        static string department;
        public Select2(string department_)
        {
            InitializeComponent();

            department = department_;
        }

        void Select(object sender, System.EventArgs e)
        {
            Button button = sender as Button;

            string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "save.txt");
            File.WriteAllText(path, department + "\n" + button.ClassId);

            Navigation.PushModalAsync(new MainPage());
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace QR
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Select1 : ContentPage
    {
        public Select1()
        {
            InitializeComponent();
        }

        void Select(object sender, System.EventArgs e)
        {
            Button button = sender as Button;

            Navigation.PushModalAsync(new Select2(Convert.ToString(button.ClassId)));
        }
    }
}
using System;
using System.IO;
using System.Net;
using System.Timers;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace QR
{
    public partial class MainPage : ContentPage
    {
        static string department = "";
        static string otk = "";
        public MainPage()
        {
            InitializeComponent();

            Device.StartTimer(new TimeSpan(0, 0, 1), checkNotice);

            string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "save.txt");
            if (File.Exists(path))
            {
                string[] text = File.ReadAllText(path).Split('\n');
                department = text[0];
                otk = text[1];
            } else
            {
                Navigation.PushModalAsync(new Select1());
            }
        }

        bool checkNotice()
        {
            string url = "http://code-factory.site/api/notice/" + Convert.ToString(department);
            WebClient webClient = new WebClient();

            if (webClient.DownloadString(url) != "")
            {
                DisplayAlert("Внимание", "Есть уведомления", "ОK");
            }

            return true;
        }

        void Orders(object sender, System.EventArgs e)
        {
            Navigation.PushModalAsync(new Orders());
        }

        void Work(object sender, System.EventArgs e)
        {
            Navigation.PushModalAsync(new Work(department, otk));
        }

        void Change(object sender, System.EventArgs e)
        {
            Navigation.PushModalAsync(new Select1());
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace QR
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Camera : ContentPage
    {
        string development, otk;
        public Camera(string development_, string otk_)
        {
            InitializeComponent();

            otk = otk_;
            development = development_;
        }

        void ScanResult(object sender, System.EventArgs e)
        {
            ZXing.Result result = scanView.Result;

            Navigation.PushModalAsync(new Work(development, otk, result.Text));
        }
    }
}

Ответы (0 шт):