Bug 60197

Summary: Build.Serial throws an exception on < API 26
Product: Android Reporter: Jim Bennett <jimbobbennett>
Component: Android+BCL IntegrationAssignee: Marek Habersack <grendel>
Severity: normal CC: jon.douglas, mono-bugs+monodroid
Priority: ---    
Version: 8.0 (15.4)   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Jim Bennett 2017-10-15 22:06:09 UTC
The underlying Java implementation for Android.OSBuild.Serial has changed from a field called SERIAL to a getSerial method. Unfortunately both implementations map to a C# property called Serial meaning the old API has been replaced. If you call Serial on an app build using API 26 on a device running API25 or less you get a missing method exception.

There is no workaround as the pre-26 SERIAL field is no longer available, you have to access it via reflection:

if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
    serial = Build.Serial;
    var field = Java.Lang.Class.FromType(typeof(Build)).GetField("SERIAL");
    serial = field.Get(null).ToString();
Comment 1 Jon Douglas [MSFT] 2017-10-15 23:30:10 UTC
This is fixed in upcoming 15.4 and 15.5 builds. I'm marking this as a duplicate. Thanks for the report!

*** This bug has been marked as a duplicate of bug 60069 ***