Bug 26057 - Forms giving an error on iOS, but not on Android
Summary: Forms giving an error on iOS, but not on Android
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.1
Hardware: All Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-01-15 05:57 UTC by Paul Johnson
Modified: 2016-04-08 18:51 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Paul Johnson 2015-01-15 05:57:46 UTC
I have the following in my forms constructor

public App()
            GoogleAPIKey = "AIzaSyBFybKfCGno1VZW4YoRy97hSNb6gQNM-nQ";
            WeatherID = "61b08439dc2bc6c53ebcfb732d5453c7";
            Singleton = this;
            Timer = 3000;
            DBManager = new DBManager();
            Sync = new SyncManager();
            UIChangedClass = new UIChangedEvent();
            User = new UserDetails();
            // Filer = new IFiler();
            DeviceId = "";
            MyBlue = Color.FromRgb(54, 141, 239);
            MainPage = new Login();

In my droid code

protected override void OnCreate(Bundle bundle)

            var l = new GroupShootDroid(Android.App.Application.Context.ApplicationContext);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            global::Xamarin.Forms.Forms.ViewInitialized += (object sender, Xamarin.Forms.ViewInitializedEventArgs e) =>
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                    e.NativeView.ContentDescription = e.View.StyleId;

            LoadApplication(new App());


public class MyAppDroid
        public static MyAppDroid Singleton { get; private set; }

        const string TAG = "GCM-CLIENT";

        public MyAppDroid(Context c)
            MyAppDroid.Singleton = this;
            AppContext = c;
 var teleManager = (TelephonyManager)c.GetSystemService(Context.TelephonyService);
            App.DeviceId = teleManager != null ? teleManager.DeviceId : DeviceId;

and in my iOS app delegate

App.DeviceId = DeviceId;

The DeviceId code is the same on both platforms

private string DeviceId
                var sb = new StringBuilder();
                string[] allowed =
                        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
                        "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
                int next = 0;
                Random r = new Random();
                for (int n = 0; n < 15; ++n)
                    next = r.Next(36);

                return sb.ToString();

The android code works fine, the iOS code falls over with an InitializerException

=== Xamarin Studio ===

Version 5.7 (build 661)
Installation UUID: f3d1a29c-1ba2-4a83-a193-1087efe91a85
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: dfb682f
Build date: 2015-01-08 13:39:32-0500

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/PFJ/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

=== Operating System ===

Mac OS X 10.10.2
Darwin Pauls-iMac.local 14.1.0 Darwin Kernel Version 14.1.0
    Sun Dec 28 21:20:58 PST 2014
    root:xnu-2782.10.72~3/RELEASE_X86_64 x86_64
Comment 1 Udham Singh 2015-01-16 05:17:48 UTC
I have tried to reproduce this issue with help of code provided in bug description but not able to reproduce this.

Could you please provide a sample app that demonstrate this issue? So that we can reproduce this issue at our end. 

Also please include application output and Ide logs. You can get Ide logs via 'XS > Help > Open Log Directory and get the latest Ide logs'.

Comment 2 Rui Marinho 2016-04-08 18:51:05 UTC
Thank you for your bug report. As we have not received the information required to properly triage your bug, we cannot properly triage your bug and are marking it resolved.

Warm regards,
Xamarin Forms Team