Forum Xamarin Xamarin.Android

Xamarin.Android and "Foreign" Languages

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

Answers

  • BillyLiuBillyLiu Member, Xamarin Team Xamurai

    @DanDickerson

    Do you get any error message?

  • DanDickersonDanDickerson USMember ✭✭

    No, it just says that the Application has stopped

  • BillyLiuBillyLiu Member, Xamarin Team Xamurai

    @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

  • DanDickersonDanDickerson USMember ✭✭

    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?

  • BillyLiuBillyLiu Member, Xamarin Team Xamurai
    edited September 2018

    @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.

  • psyonpsyon USMember ✭✭

    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.

  • psyonpsyon USMember ✭✭

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

Sign In or Register to comment.