Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7199

App keeps stopping (only on apk from Azure DevOps)?

$
0
0

We are deploying our Xamarin android app inhouse using Azure DevOps. The App builds, deploys, and runs smoothly from VS2019. We are also able to sign our apk using the Android Package Signing option.

Building, signing, and placing the .apk from Azure DevOps works fine but we were/are encountering a hang and a crash (separately). If we remedy the hang, the crash occurs.

Before checking the 'Zipalign' option our app would hang on the SplashActivity. After checking the 'Zipalign' option, our app appears to switch from SplashActivity to MainActivity but then crashes and says "App keeps stopping". What to try from here? No idea how to debug the issue as this does not occur when deploying debug or release from VS.

Edit1

Tried implementing error handling to catch the errors but it doesn't appear to be getting hit.

protected override void OnCreate(Bundle bundle){    TabLayoutResource = Resource.Layout.Tabbar;    ToolbarResource = Resource.Layout.Toolbar;    base.OnCreate(bundle);    AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;    System.Threading.Tasks.TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;    Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser += OnAndroidEnvironmentUnhandledExceptionRaiser;    global::Xamarin.Forms.Forms.Init(this, bundle);    DisplayCrashReport();    LoadApplication(new App());}#region Error handlingpublic static void TaskSchedulerOnUnobservedTaskException(object sender,    System.Threading.Tasks.UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs){    var newExc = new Exception("TaskSchedulerOnUnobservedTaskException", unobservedTaskExceptionEventArgs.Exception);    LogUnhandledException(newExc);}public static void CurrentDomainOnUnhandledException(object sender,     UnhandledExceptionEventArgs unhandledExceptionEventArgs){    var newExc = new Exception("CurrentDomainOnUnhandledException", unhandledExceptionEventArgs.ExceptionObject as Exception);    LogUnhandledException(newExc);}private void OnAndroidEnvironmentUnhandledExceptionRaiser(object sender,     Android.Runtime.RaiseThrowableEventArgs unhandledExceptionEventArgs){    var newExc = new Exception("OnAndroidEnvironmentUnhandledExceptionRaiser", unhandledExceptionEventArgs.Exception);    LogUnhandledException(newExc);}internal static void LogUnhandledException(System.Exception exception){    try    {        const string errorFileName = "Fatal.log";        var libraryPath = System.Environment.GetFolderPath(            System.Environment.SpecialFolder.Personal); // iOS: Environment.SpecialFolder.Resources        var errorFilePath = System.IO.Path.Combine(libraryPath, errorFileName);        var errorMessage = System.String.Format("Time: {0}\r\nError: Unhandled Exception\r\n{1}",        System.DateTime.Now, exception.ToString());        System.IO.File.WriteAllText(errorFilePath, errorMessage);        // Log to Android Device Logging.        Android.Util.Log.Error("Crash Report", errorMessage);    }    catch    {        // just suppress any error logging exceptions    }}/// <summary>// If there is an unhandled exception, the exception information is diplayed // on screen the next time the app is started/// </summary>[System.Diagnostics.Conditional("DEBUG")]public void DisplayCrashReport(){    const string errorFilename = "Fatal.log";    var libraryPath = System.Environment.GetFolderPath(        System.Environment.SpecialFolder.Personal);    var errorFilePath = System.IO.Path.Combine(libraryPath, errorFilename);    if (!System.IO.File.Exists(errorFilePath))    {        return;    }    var errorText = System.IO.File.ReadAllText(errorFilePath);    new Android.App.AlertDialog.Builder(this)        .SetPositiveButton("Clear", (sender, args) =>        {            System.IO.File.Delete(errorFilePath);        })        .SetNegativeButton("Close", (sender, args) =>        {            // User pressed Close.        })        .SetMessage(errorText)        .SetTitle("Crash Report! MainActivity")        .Show();}#endregion

Viewing all articles
Browse latest Browse all 7199

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>