Bug 53905 - An error has occurred on startup - Type initializer for 'XamarinProfiler.Core.Platforms.Android.PlatformAndroid' threw an exception
Summary: An error has occurred on startup - Type initializer for 'XamarinProfiler.Core...
Status: VERIFIED FIXED
Alias: None
Product: Profiler
Classification: Xamarin
Component: Mac ()
Version: 1.2.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 15.2
Assignee: Rodrigo Moya
URL:
Depends on:
Blocks:
 
Reported: 2017-03-24 12:31 UTC by Seb
Modified: 2017-04-19 11:20 UTC (History)
5 users (show)

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


Attachments
Attached are the logs generated during defect verification (8.85 KB, text/plain)
2017-04-19 11:20 UTC, Saurabh Paunikar
Details


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 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:
Status:
VERIFIED FIXED

Description Seb 2017-03-24 12:31:24 UTC
I've tried to install multiple versions of Xamarin Profiler (1.0.5, 1.1.99, 1.2.1) - all with the same exception on start up.

"An error has occurred" dialog appears stating:

The type initializer for 'XamarinProfiler.Core.Platforms.Android.PlatformAndroid' threw an exception.

This occurs if I try to run profiler as an application from within Applications in finder. It also occurs if I try to do a profile run from Xamarin Studio (first time trying this). 

As this is all running on OS X (10.12.3) I'm not sure why it is interested in the Android platform but any suggestions greatly received.

If there is any way to provide more useful log output please advise (not a frequent Mac user).
Comment 1 Seb 2017-03-24 14:08:45 UTC
Update:

Should have read the documentation a bit more - discovered I could get logs for Profiler from  ~/Library/Logs/Xamarin.Profiler/

Exception from logs included below. I don't think I have Xamarin Android installed on this Mac at all - as it has only been used for iOS builds. I am currently installing latest version as well as Android SDK for Mac. Will update with results once this is complete.




XamarinProfiler.Core.Profiler Information: 0 : [2017-03-24 11:45:20.5274] ##########################################
XamarinProfiler.Core.Profiler Information: 0 : [2017-03-24 11:45:20.5392] # Xamarin Profiler version -  1.2.1.3
XamarinProfiler.Core.Profiler Information: 0 : [2017-03-24 11:45:20.5392] #  * Arch x86_64
XamarinProfiler.Core.Profiler Information: 0 : [2017-03-24 11:45:20.5392] ##########################################
XamarinProfiler.Core.Profiler Critical: 0 : [2017-03-24 11:45:21.4951] uncaught exception
System.TypeInitializationException: The type initializer for 'XamarinProfiler.Core.Platforms.Android.PlatformAndroid' threw an exception. ---> System.InvalidOperationException: This property is not valid when the SDK is not installed
  at Xamarin.AndroidTools.AndroidSdk.ValidatePath (System.String path) [0x0001e] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/external/androidtools/Xamarin.AndroidTools/AndroidSdk.cs:229 
  at Xamarin.AndroidTools.AndroidSdk.get_AdbExe () [0x0000b] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/external/androidtools/Xamarin.AndroidTools/AndroidSdk.cs:130 
  at XamarinProfiler.Core.Platforms.Android.PlatformAndroid..cctor () [0x00000] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Core/Platforms/Android/PlatformAndroid.cs:17 
   --- End of inner exception stack trace ---
  at XamarinProfiler.Core.Platform.get_ProfilingPlatforms () [0x0001b] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Core/Platform.cs:105 
  at XamarinProfiler.Core.ProfilerSession.Initialize (XamarinProfiler.Core.RunFactory runFactory, System.Boolean logToFile) [0x00015] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Core/ProfilerSession.cs:31 
  at XamarinProfiler.Mac.MainClass.Main (System.String[] args) [0x00033] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Mac/Main.cs:33 
XamarinProfiler.Core.Profiler Critical: 0 : [2017-03-24 11:45:21.4951] uncaught exception
System.TypeInitializationException: The type initializer for 'XamarinProfiler.Core.Platforms.Android.PlatformAndroid' threw an exception. ---> System.InvalidOperationException: This property is not valid when the SDK is not installed
  at Xamarin.AndroidTools.AndroidSdk.ValidatePath (System.String path) [0x0001e] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/external/androidtools/Xamarin.AndroidTools/AndroidSdk.cs:229 
  at Xamarin.AndroidTools.AndroidSdk.get_AdbExe () [0x0000b] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/external/androidtools/Xamarin.AndroidTools/AndroidSdk.cs:130 
  at XamarinProfiler.Core.Platforms.Android.PlatformAndroid..cctor () [0x00000] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Core/Platforms/Android/PlatformAndroid.cs:17 
   --- End of inner exception stack trace ---
  at XamarinProfiler.Core.Platform.get_ProfilingPlatforms () [0x0001b] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Core/Platform.cs:105 
  at XamarinProfiler.Core.ProfilerSession.Initialize (XamarinProfiler.Core.RunFactory runFactory, System.Boolean logToFile) [0x00015] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Core/ProfilerSession.cs:31 
  at XamarinProfiler.Mac.MainClass.Main (System.String[] args) [0x00033] in /Users/builder/data/lanes/3894/eeffc4c2/source/profiler/src/XamarinProfiler.Mac/Main.cs:33
Comment 2 Seb 2017-03-24 14:36:14 UTC
Installing Xamarin Android and Android SDK has resolved the above issue.

Can someone clarify if Xamarin Android + SDK should need to be installed for Xamarin Profiler to work?
Comment 3 Rodrigo Moya 2017-03-27 17:35:46 UTC
hmm, right now it is indeed needed, but if you're never going to profile Android apps, it's not needed. So, we should better detect it's not installed instead of crashing, so leaving this open so that we can fix that
Comment 4 xamarin-release-manager 2017-04-18 13:28:02 UTC
Fixed in version 1.5.99.65 (master)

Author: Rodrigo Moya
Commit: 60adeaaadda8e5d533b45d4837dac64df812a3f1 (xamarin/profiler)
Comment 5 Saurabh Paunikar 2017-04-19 11:20:10 UTC
Created attachment 21619 [details]
Attached are the logs generated during defect verification


Verified on Xamarin Profiler version 1.5.99.65 (master)
Screencast link: https://www.screencast.com/t/Qg0JeB0m