Skip to content

[Android] OnIdiom throws NotImplementedExceptionΒ #29853

@fagertjan

Description

@fagertjan

Description

Our customer reports crashes in our maui app. In appcenter we find this crash multiple times. It happens on their Galaxy XCover 5 with Android 14. We had this issue in maui 9.0.21 but have it also in 9.0.70. I cannot reproduce it myself.

We use the OnIdiom in a getter like this:

public static class AppConstants
{
    public static double TaskListItemHeight => new OnIdiom<double>()
    {
        Phone = 140,
        Tablet = 160,
        Desktop = 160
    };
}

And then use that getter in code like this:
var xyz = AppConstants.TaskListItemHeight;

The exception with relevant stack trace is:
System.NotImplementedException: Do not know how to dispose: Invalid.

Java.Interop.JniObjectReference.Dispose(JniObjectReference& )
Java.Interop.JniRuntime.JniValueManager.DisposePeer(JniObjectReference , IJavaPeerable )
Java.Interop.JniRuntime.JniValueManager.DisposePeer(IJavaPeerable )
Java.Lang.Object.Dispose()
Microsoft.Maui.Devices.DeviceInfoImplementation.get_Idiom()
Microsoft.Maui.Devices.DeviceInfo.get_Idiom()
Microsoft.Maui.Controls.OnIdiom`1[[System.Double, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].op_Implicit(OnIdiom`1 onIdiom)
AppConstants.get_TaskListItemHeight()
...

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

No response

Affected platforms

Android

Affected platform versions

14

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

Labels

s/needs-attentionIssue has more information and needs another lookt/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions