locked
Xamarin.Android and "Foreign" Languages RRS feed

  • Question

  • User333966 posted

    I have an App in the Play Store that works fine in English. I recently received a message from a user that it crashes upon launch on his Samsung Galaxy Tab A (Android 7) that was set up with French as the main language. Testing has shown that it works fine under Spanish, German, and Italian. Under French, Polish, and Portuguese, it fails on launch. In each case, I performed a Factory Reset to change the language. If the user adds English in the settings, AND makes it the primary language, they can run the App with no problems. The user can then restore their chosen language as the default and the App will continue to work just fine. Other than sqlite, I am not doing anything out of the ordinary.

    Has anyone else seen this problem? Any suggestions on how to fix it so that these steps are not necessary? Do I have to worry about iOS, Forms, and UWP programs?

    Thanks, Dan

    Tuesday, September 25, 2018 10:34 PM

All replies

  • User364855 posted

    @DanDickerson

    Do you get any error message?

    Wednesday, September 26, 2018 5:05 AM
  • User333966 posted

    No, it just says that the Application has stopped

    Wednesday, September 26, 2018 2:03 PM
  • User364855 posted

    @DanDickerson

    Which project are you using? Xamarin.Forms or Xamarin.Android? They are using different tech for localization. https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/localization https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/

    And you need to use Android Debug Log to get some info about your crash. It will help to find and solve the problem. https://docs.microsoft.com/en-us/xamarin/android/deploy-test/debugging/android-debug-log?tabs=vswin

    Thursday, September 27, 2018 2:19 AM
  • User333966 posted

    I ran the App using USB debugging, and I think that I found the problem. It appears to be the lines:

        var prefs = Application.Context.GetSharedPreferences("FubarApp", FileCreationMode.Private);
        foo = Convert.ToDouble(prefs.GetString("fooval", "0.0"));
    

    It worked once I changed it to

        foo = Convert.ToDouble(prefs.GetString("fooval", "0"));
    

    Once I load in the values, they are saved back out to the system, so the default value is only referenced the first time that the program runs. That is why running it once with English as the primary language fixes the problem.

    Poland, Portugal, and France all use the decimal comma, so I can see why it fails. Germany, Italy, and Spain also use the decimal comma, so I would have expected it to fail there, also.

    At issue though, is what should I do if the default value is not an integer? Say, "1.5"? Is there a way to have the GetString routine to return the correct format?

    Thursday, September 27, 2018 4:50 AM
  • User364855 posted

    @DanDickerson

    Poland, Portugal, and France all use the decimal comma, so I can see why it fails. Germany, Italy, and Spain also use the decimal comma, so I would have expected it to fail there, also.

    This issue we have met before. After we research, we found that it only happens on some devices. https://forums.xamarin.com/discussion/comment/339061/#Comment_339061 I think you could try to use , instead of . in some language. Or use the calculation to create the double.

    You could post this issue to Samsung support forum.

    Thursday, September 27, 2018 5:28 AM
  • User286402 posted

    This appears to be an old issue, but I recently started having the same problems. A user contacted me about my app crashing. They use the French language. I fired up my app in an emulator, set the language to French, and the app crashes. It actually freezes up for a while, then crashes. While it's frozen, the output is going back and forth allocating memory and the garbage collector freeing stuff. The lines that cause the issue are when I bind to a property that is a double.

    entryLatitude.SetBinding(Xamarin.Forms.Entry.TextProperty, "latitude");
    

    If I comment out that line, and three others that bind longitude, altitude, and accuracy which are all doubles, the app works fine.

    Tuesday, June 9, 2020 12:26 AM
  • User286402 posted

    I fixed this by just setting the default culter to en-US.

    Tuesday, June 9, 2020 1:38 PM