-
Notifications
You must be signed in to change notification settings - Fork 564
Description
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS2022 17.5.4, .NET 7 Android
Description
When building an app with PublishTrimmed enabled, changing the device timezone crashes the app:
[monodroid] Unable to find Android.Runtime.AndroidEnvironment.NotifyTimeZoneChanged()!
illinker seems to remove the method.
The timezone is often automatically changed by getting close to an other country, even though the time itself doesn't change. (changes to Europe/Amsterdam to Europe/Berlin)
The timezone can also be changed manually in the Android settings for the same effect.
Steps to Reproduce
Attached is a new Android 7 app with PublishTrimmed enabled in debug mode which shows the started timestamp in UI.
Start the app from Visual Studio in debug mode and note the time. Go to Android settings and change the current timezone to for example Afghanistan.
The app immediately crashes, VS stops debugging and the log shows the error message that AndroidEnvironment.NotifyTimeZoneChanged() is missing.
This happens in both emulator-33 and physical devices.
Did you find any workaround?
Add a linker description file containing:
<linker>
<assembly fullname="Mono.Android">
<type fullname="Android.Runtime.AndroidEnvironment">
<method name="NotifyTimeZoneChanged" /> <!-- Workaround for Xamarin bug trimming method away -->
</type>
</assembly>
</linker>
To prevent the method being trimmed away.
Relevant log output
No response