Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

System.BadImageFormatException thrown by String.CompareTo

GeorgeauxGeorgeaux USMember ✭✭
edited September 2018 in Xamarin.Android

The following BadImageFormatException occurs when comparing strings on Samsung SM-A310F device (Android 7.0).

Xamarin caused by: android.runtime.JavaProxyThrowable: **System.BadImageFormatException**: _Invalid method header format 0
File name: 'mscorlib'_

Stack trace:

System.Globalization.CompareInfo.internal_compare_managed(string str1, int offset1, int length1, string str2, int offset2, int length2, CompareOptions options)

System.Globalization.CompareInfo.internal_compare_switch(string str1, int offset1, int length1, string str2, int offset2, int length2, CompareOptions options)

System.Globalization.CompareInfo.Compare(string string1, string string2, CompareOptions options)

System.String.CompareTo(string strB)

Any ideas?

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai
    edited September 2018

    @Georgeaux

    Sorry I do not have any ideas especially if it is only reproducible on that specific device.

    Have you tried this on other devices or emulators? It also may help to show the exact code you are running and the strings you are comparing so there is some context that may be used to track the issue down.

  • GeorgeauxGeorgeaux USMember ✭✭

    Only two specific users are affected by the error, both using Samsung SM-A310F with Android 7.0.

    Crash appeared after we changed "Target Framework" to Android 8.1 ( it can be a coincidence )

    < image that i cannot post >

    The text true CompareTo true or false

    I suspecting that a local specific issue crashes the compare. ( cause the crash pops up from System.Globalization )

  • GeorgeauxGeorgeaux USMember ✭✭
    edited September 2018

    true and false strings declared as static readony

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @Georgeaux

    It may help to get the Android device logs (adb logcat) immediately after the crash occurs.

    ADB logcat info.

    Ideally do this shortly after running your app on the device and the issue occurs. It will generate a "logcat.txt" file on your Desktop.

    1. To get the adb logcat info, with your device or emulator connected to your workstation, open Terminal (Mac) or the Command Line (Windows) and navigate to your Android SDK platform tools directory:
      Mac: ~/Library/Developer/Xamarin/android-sdk-mac_x86/platform-tools
      Windows: %LOCALAPPDATA%\Android\android-sdk\platform-tools
      (If your android SDK path is different, you can find the path by opening your Android SDK manager and the path is noted at the top)

    2. Once in the appropriate directory, type (for Mac):
      ./adb logcat -vtime -d > ~/Desktop/logcat.txt
      or type (for Windows):
      adb logcat -vtime -d > "%UserProfile%\Desktop\logcat.txt"

    For more info, please see: http://docs.xamarin.com/guides/android/deployment,_testing,_and_metrics/android_debug_log/

Sign In or Register to comment.