locked
App runs ok in simulator, runs OK in Debug mode on device, but crashes when published to device RRS feed

  • Question

  • User127230 posted

    This is a truly odd situation since it is impossible for me to debug because it runs OK in Debug mode !!!

    The app consists of a Login page which contains a TableView, a TextField, and a Button. Users select their userID from the table, enter their pin number in the box, and press the login button. The ViewController has been designed in IB as a XIB file. All outlets have been included in the header .h file shown below:

    // WARNING // This file has been generated automatically by Xamarin Studio to // mirror C# types. Changes in this file made by drag-connecting // from the UI designer will be synchronized back to C#, but // more complex manual changes may not transfer correctly.

    import

    import

    @interface LoginPage : UIViewController { UIActivityIndicatorView *LoginBusyIndicator; UIButton *LoginButton; UITextField *UsersIDEntry; UITableView *UsersSelectionList; }

    @property (nonatomic, retain) IBOutlet UIActivityIndicatorView *LoginBusyIndicator;

    @property (nonatomic, retain) IBOutlet UIButton *LoginButton;

    @property (nonatomic, retain) IBOutlet UITextField *UsersIDEntry;

    @property (nonatomic, retain) IBOutlet UITableView *UsersSelectionList;

    • (IBAction)OnLoginCommand:(id)sender;

    @end

    The app crashed the minute I reference the Table, only when packed and installed in release mode into the iPad iOS V8

    using System; using System.Collections.Generic; using Foundation; using UIKit; using TestAPP.Model; // local package using TestAPP.Helper; // local package

    namespace TestAPP { public partial class LoginPage : UIViewController { String[] empName;

        public LoginPage () : base ("LoginPage", null)
        {
        }
    
        public override void DidReceiveMemoryWarning ()
        {
            // Releases the view if it doesn't have a superview.
            base.DidReceiveMemoryWarning ();
    
            // Release any cached data, images, etc that aren't in use.
        }
    
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
    
            // Perform any additional setup after loading the view, typically from a nib.
        }
    
        public void Reset()
        {
            UsersIDEntry.Text = "";
            UsersIDEntry.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
        }
    
        // Called from ApplicationDelegate once all is initialised and ready
        public void PopulateEmployeesNames ( List<Employee> employeesData)
        {
            try
            {
                LoginBusyIndicator.StopAnimating ();
                LoginBusyIndicator.Hidden = true; 
    
                empName = new string[employeesData.Count];
                int index = 0;
                foreach (var employee in employeesData)
                    empName[index++] = employee.check_name;
                // CRASHES HERE. Works OK if these 2 lines are removed
                ((UIKit.UITableView) UsersSelectionList).Source = new EmployeeLoginTableSource (empName);
    
    
                UsersSelectionList.ReloadData ();
            } catch (Exception e) {
                new UIKit.UIAlertView ("Error", "This never gets called!!!" + e.ToString(), null, "Continue").Show ();
            }
        }
    
        partial void OnLoginCommand(Foundation.NSObject sender)
        {
            //new UIKit.UIAlertView ("Yo!", "Error DUDE! Server sent some shit!!!", null, "Continue").Show ();
            AppDelegate _theAppDelegate = (AppDelegate) UIApplication.SharedApplication.Delegate;
            _theAppDelegate.KillLoginAndSwapRootToMain();
        }
    }
    

    }

    Below is the EmployeeLoginTaleSource

    using System; using System.Collections.Generic; using System.IO; using Foundation; using UIKit;

    namespace TestAPP.Helper { public class EmployeeLoginTableSource : UITableViewSource { string[] TableItems; string cellIdentifier = "TableCell";

        public EmployeeLoginTableSource (string[] items)
        {
            TableItems = items;
        }
    
        public override nint NumberOfSections (UITableView tableview)
        {
            return 1;
        }
    
        public override nint RowsInSection (UITableView tableview, nint section)
        {
            return TableItems.Length;
        }
    
        public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier);
            string item = TableItems[indexPath.Row];
    
            cell.TextLabel.Text = item;
    
            return cell;
        }
    }
    

    }

    Any ideas?

    Saturday, June 6, 2015 8:56 AM

Answers

  • User129255 posted

    To give a little hint:

    linker can cause trouble while used in project with json attributes. That's because if linker thinks that some code is not used, then it can remove that code. That's trouble with json which mainly uses JsonAttribute as description of data.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, June 7, 2015 10:25 PM
  • User3047 posted

    I've experienced this exact issue and the linker was the cause for me as well. I think 8.10.1.64 helped may have helped, but I had to roll back to 8.9.1.3 because of a NTLM authentication issue introduced in 8.10.x.x. The first link JawadRiachi posted was especially interesting, if obviously a bit kludgy. I'll give that a go as without linking my release build is huge compared to a properly linked version.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, June 8, 2015 2:27 AM

All replies

  • User1669 posted

    So what was the error and stack trace?

    Saturday, June 6, 2015 5:17 PM
  • User127230 posted

    It seems that there are multiple issues with Tasks and HTTPRequests. Some are related to the linker.

    I went through the URLs below and they made sense to my situation.

    http://developer.xamarin.com/guides/ios/advanced_topics/linker/

    https://lostechies.com/jimmybogard/2014/11/11/dealing-with-the-linker-in-xamarin-apps/

    I am restructuring the sample app experimenting with JSON and HAL. I have not reached a point of resolution yet. I will share the experience once I do.

    Sunday, June 7, 2015 6:43 AM
  • User129255 posted

    To give a little hint:

    linker can cause trouble while used in project with json attributes. That's because if linker thinks that some code is not used, then it can remove that code. That's trouble with json which mainly uses JsonAttribute as description of data.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, June 7, 2015 10:25 PM
  • User3047 posted

    I've experienced this exact issue and the linker was the cause for me as well. I think 8.10.1.64 helped may have helped, but I had to roll back to 8.9.1.3 because of a NTLM authentication issue introduced in 8.10.x.x. The first link JawadRiachi posted was especially interesting, if obviously a bit kludgy. I'll give that a go as without linking my release build is huge compared to a properly linked version.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, June 8, 2015 2:27 AM
  • User127230 posted

    My resolution is as follows. Develop in small sprints. Run every sprint on the device in release mode. Once running check in GIT (or SVN...) and label as stable. If it crashes, tweak with the linking options until you get it running. If you fail, roll back from GIT and start again in even smaller sprints. It is a slow process, but better than going through a whole application on the simulator thinking that everything is dandy only to discover later that your application has problems and try to figure out where the problems are. This is what I am doing at the moment. Remember, I am new to the environment. I may change the method once I feel more confident.

    Monday, June 8, 2015 3:47 AM