Bug 31228 - [Android] app crashes with "Not a valid calendar for the given culture" when using Thai as system language
Summary: [Android] app crashes with "Not a valid calendar for the given culture" when ...
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 5.1
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Marek Habersack
Depends on:
Reported: 2015-06-18 12:43 UTC by Amalia
Modified: 2017-08-29 05:04 UTC (History)
12 users (show)

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

Sample app (39.87 KB, application/zip)
2015-06-18 12:43 UTC, Amalia

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 Amalia 2015-06-18 12:43:35 UTC
Created attachment 11669 [details]
Sample app

### Overview

When the attached app is run on an Android phone with the language set to Thai, pressing the button on the app crashes the app. When you press the button, all it's supposed to do is replace its text with a number string representing the current date and time.

### Steps to reproduce

1. Set the language on a physical Android phone to Thai.

2. Download the attached app (thaiChrash) and run it on the phone in Release mode.

3. Press the button ("Click to Crash").

4. App will crash.

### Actual results

App crashed. Error messages: https://gist.github.com/amaliasafer/423b9519fa6a3b79d7ed

### Expected results

App doesn't crash. Button text becomes a number representing the current date and time.

### Additional information

Crash was on Moto E with Android version 5.0.2

=== Xamarin Studio ===

Version 5.9.3 (build 1)
Installation UUID: 1f52eea2-a387-4a2c-96c1-4637c8f8567a
	Mono 4.0.1 ((detached/ed1d3ec)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010044

=== Apple Developer Tools ===

Xcode 6.3.2 (7718)
Build 6D2105

=== Xamarin.Android ===

Version: (Enterprise Edition)
Android SDK: /Users/amalias/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Enterprise Edition)

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: e6ebd18
Branch: master
Build date: 2015-05-21 21:55:09-0400

=== Build Information ===

Release ID: 509030001
Git revision: 5a524e1726ed103fdd4fe37e0356f2b35466ce9d
Build date: 2015-06-02 16:35:08-04
Xamarin addins: 51957cfbd06be911b212671ad05c2c6221ac90f9

=== Operating System ===

Mac OS X 10.10.3
Darwin amalias.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Dominic N [MSFT] 2015-06-18 13:15:27 UTC
Also was able to replicate this issue on a Moto E running 5.0.2. Marking as confirmed.
Comment 3 Rajneesh Kumar 2015-06-18 14:36:04 UTC
I have checked this issue and able to reproduce this using the XAP emulator. To reproduce this issue I have followed the the steps and instruction provided in bud description. 

After setting the emulator language to THAI and running the application in release mode when I Press the button ("Click to Crash"), I observed that app goes crash.

Screencast: http://www.screencast.com/t/vItoaAOwno

Additional Information: Application works works fine when I select English language.

Application Output: https://gist.github.com/Rajneesh360Logica/82a8ee337275d9b31f00
Ide Logs: https://gist.github.com/Rajneesh360Logica/09a684c82c38c26dcd61
XAP Emulator Logs: https://gist.github.com/Rajneesh360Logica/c606af99e37545cc1ae7
Build output: https://gist.github.com/Rajneesh360Logica/cda5e3c099cae6ab1a71

Environment Info:

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		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.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 96f4a3a
Branch: master
Build date: 2015-06-12 18:49:46-0400

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 4 Luzanne 2015-06-25 10:06:00 UTC
Workaround, force Thai culture to English culture

 var localeIdentifier = Java.Util.Locale.Default.ToString();
 if (localeIdentifier == "th_TH")
     CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
Comment 5 Randall Schmidt 2016-02-16 16:04:08 UTC
This exists on iOS also. Changing the CurrentCulture to English fixes the crash but then number formatting and such uses the wrong locale.
Comment 6 Dominic N [MSFT] 2016-02-16 16:56:16 UTC
Randall - if you're hitting this on iOS as well, I'd highly suggest filing a new, separate bug with details and a description of the issue with iOS. This bug only addresses Android.

You can file a new bug here: https://bugzilla.xamarin.com/newbug
Comment 7 Randall Schmidt 2016-02-18 21:56:14 UTC
For reference, iOS bug report filed here: https://bugzilla.xamarin.com/show_bug.cgi?id=38891
Comment 8 Marek Habersack 2016-08-31 15:03:33 UTC
This problem no longer exists in the current master and cycle8 builds of XA
Comment 11 gcnew 2017-08-29 05:04:16 UTC
For those who still suffer from this bug see the following: