Forum Xamarin Xamarin.Android

Here is a HockeyApp Binding for Xamarin.Android on GitHub

It includes an additional class, TraceWriter, which allows you to log exceptions that come from .NET into HockeyApp. Exceptions are reported to HockeyApp and are properly grouped. You will see both java and c# based exceptions.

The tricky thing is that you have to integrate it into how you work with Tasks, since the .NET uncaught task exception only reports when a Task has an exception and is finalized. I never saw this happen, so I suspect some part of the framework is holding onto a reference.

There are some more details in the README on github.


  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    Awesome! Thank you for sharing!

  • This is good stuff. Thanks T.J.!

  • DirkSchiffnerDirkSchiffner DEMember

    Any chance to get that working with HockeySDK-3.0.0.jar (current version)? I have some trouble to compile that with 4.7.11...


  • T.J.Purtell.1752T.J.Purtell.1752 USMember ✭✭

    I updated it. It needed some tweaks to metadata.xml to filter out some internal classes.

  • EchieEchie USMember

    Hey, thanks for sharing this!

    I'm trying to use the latest commit (dca151239c, from 20 days ago), but calling FeedbackManager.showFeedbackActivity gives me an exception, saying:

    android.content.ActivityNotFoundException: Unable to find explicit activity class {/}; have you declared this activity in your AndroidManifest.xml?

    Note that the namespace is prepended by my own namespace (like, com.example/net.hockeyapp...). I'm trying to figure it out, but has anyone got feedback working?

    Thanks :)

  • EchieEchie USMember

    Ah, nevermind. I was putting the <activity... declarations outside the <application... tag :P

    Works like a charm, thanks! :)

  • nickNaylornickNaylor DEMember ✭✭

    hmm, I only see the exception itself but not the stacktrace.
    I did it as described in the readme...

    any idea?

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai
  • nickNaylornickNaylor DEMember ✭✭

    @JamesMontemagno‌ great, I will give it a try ASAP :)

  • nickNaylornickNaylor DEMember ✭✭

    @JamesMontemagno‌ sadly not even one of our (easy) testcrashes is shown on, neither on Android nor on iOS, when using the Xamarin Components :(

  • nickNaylornickNaylor DEMember ✭✭

    @JamesMontemagno‌ iOS seem to work (except we have a problem with dsym, but we will probably find out)... We still had some bugsense code active :/

  • TedRogersTedRogers USMember ✭✭✭✭

    @JamesMontemagno‌ I just wired this into my Android app and also am not seeing any crashes reported after I put in code to force a crash.
    Any ideas?

  • TedRogersTedRogers USMember ✭✭✭✭

    @T.J.Purtell.1752 - Great stuff. I was able to wire your bindings in and it works like a charm! Thanks for that and for any help you or others might be able to provide with my questions below.

    1. How do I get symbols up to HockeyApp? It seems to be looking for a mappings.txt file to upload. How do I create that or is there something I need to do different in my build process? I do have symbols included in the build I am uploading to HockeyApp.
    2. On HockeyApp it says no stack trace available in the overview but when I go into "Crash Logs" I see the stack trace under Logs. Is that the expected behavior?
  • T.J.Purtell.1752T.J.Purtell.1752 USMember ✭✭

    @TedRogers The "Log" section is where I see my (.NET) crash stack traces as well. This is because they don't look like Java/ObjC stack traces. I suspect you could reformat the traces manually to take advantage of this hockey app functionality, but I haven't had the time to do it yet. Sometimes this means that several related traces will be bundled together under one category in HockeyApp.

    Because of the way HockeyApp works on Android, it does not catch native crashes (e.g. SIGSEGV, SIGBUS, SIGILL), so there is no need to provide NDK symbols.

    For iOS, I upload the zipped dsym's manually when I make builds. I think the app traces do work there because the code is fully AOT processed. That said, I find the managed exceptions to provide much better error detail.

  • TedRogersTedRogers USMember ✭✭✭✭

    @T.J. - I feeling like the secret sauce was not as much the bindings as the extra code and classes you provided. Thanks again.

    Is there any reason the Xamarin component won't work just as well as your bindings as long as you have your other secret sauce in place?

    What bindings do you use for iOS?

  • T.J.Purtell.1752T.J.Purtell.1752 USMember ✭✭
    edited March 2014

    @TedRogers You are right about the "secret sauce" part. If you use that code with the Xamarin component, I expect it will provide the same functionality.

    For iOS, I also have shared my binding on github, . Though this binding is much more primitive (e.g. implements only the bare minimum of what I needed). I just added a README to it so you can see how I wired it up.

  • alienpaperalienpaper GBMember ✭✭
    edited April 2014

    My own experience today has mirrored the discussion above...

    • bad news: the official Xamarin extension did not log crashes at all
    • good news: by adding @TJPurtell1752's class TraceWriter to the project, and his modified OnResume() method to the main activity, the official extension started logging all the things

    Thanks @TedRogers, @TJPurtell1752 and @JamesMontemagno for saving me some time.

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

    @Danyal, thank you for the feedback on this. I will have the team look at it.

  • TedRogersTedRogers USMember ✭✭✭✭

    @T.J.Purtell.1752 - I wired in the Xamarin bindings for HockeyApp for iOS and used your code which converts exceptions to NSException. It seems to be working well for exceptions on the UI thread as well as from the thread pool. What is the reasoning for converting them to NSException?

    I call this function prior to calling the Xamarin EnableCustomCrashReportng() in FinishedLaunching().

    void EnableCrashReporting ()
        AppDomain.CurrentDomain.UnhandledException +=
            (sender, args) => ConvertToNsExceptionAndAbort(args.ExceptionObject, 0);
        TaskScheduler.UnobservedTaskException += (sender, args) => ConvertToNsExceptionAndAbort(args.Exception, 1);
        ExceptionSupport.UncaughtTaskExceptionHandler = ConvertToNsExceptionAndAbort;


  • T.J.Purtell.1752T.J.Purtell.1752 USMember ✭✭

    The conversion to an exception is so that it can be reported to ios as an uncaught exception. This triggers the plcrashreporter framework in hockeyapp to write stack traces so that a crash report is generated. The conversion also takes the stack trace and sets it up as the message for the crash so that the a nice managed stack trace is available on hockeyapp.

  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    Am I right that the bindings from @T.J.Purtell.1752 will not catch any SIGSEGV or SIGBUS exceptions? Is there a workaround available?

  • T.J.Purtell.1752T.J.Purtell.1752 USMember ✭✭

    @Sebastian‌ I have not found one. Though I didn't really look.

  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    @T.J.Purtell.1752 thanks for the response. I think I have done something wrong for now.

  • EnzignEnzign SEMember

    I couldn't get the Xamarin Component to get any crash reports either, but with your project it was a no brainer. Thanks TJ!

  • T.J.Purtell.1752T.J.Purtell.1752 USMember ✭✭

    I updated the project to improve the stack trace grouping.

    After using the crash reporting for awhile, I have found that the stack trace grouping was not adequate for my needs. HockeyApp was getting confused about two things.
    (1) It was not identifying the lines of the managed C# stack traces as stack frames
    (2) After that was resolved, it was not identifying code for my app (and instead showing system code) as the reason on the crash group summary.

    I basically reformatted the exception traces systematically to address these. Note that it does actually change what the traces look like somewhat. There shouldn't be any loss of information, but you will have to get used to interpretting a slightly different format. The benefits for me of having traces grouped correctly (based on stack trace and not just message) are well worth it.

    Here is a summary of the changes of the formatting
    (1) A package name is prepended to classes that it thinks are in your app,
    (2) Spacing changes to make C# stack frames match the java format
    (3) Arguments to method are converted into something that is a legal filename to match the java format
    (4) A fake line number (1337) is added to match the java format
    (5) Aggregate exceptions are reported as just the most inner exception causing the issue. You can report the full exception via the custom crash listener description.

  • nickNaylornickNaylor DEMember ✭✭

    @T.J. Purtell
    is it possible, that a few informations do get lost?

    I posted some rather equal logs from the old and the new reporter, which are probably both caused by an "out of memory" exception. In the old one the "out of memory" information is given somewhere, but in the new one it only says "Java.lang.error", which says nothing and does not really help to find the crash...

    You can find the logs at: .

    So far I only got this single crash report so I cant say much. But if that "out of memory" (or similar informations) are now let out, this would be a real problem for me...

  • JohnBotibolJohnBotibol GBMember ✭✭

    @T.J. Purtell
    Thank you for this, extremely useful.
    How about fixing the component please (or remove it from the store to stop people wasting their time with it?)

  • RobertKwokRobertKwok USMember

    If you guys are looking for a fully supported crash reporting solution for Xamarin which gracefully supports SIGSEGVs, etc. Crittercism just released theirs to the component store (full-disclosure: I'm one of the co-founders):

  • JohnBotibolJohnBotibol GBMember ✭✭

    Does Crittercism offer deployment just like HockeyApp or TestFlight?

  • MikhailMelnikMikhailMelnik AUMember ✭✭

    Is there any way to get .Net line numbers in a stack trace?

  • I was wondering in the line numbers could be somehow added to the stack trace in release builds as well...

Sign In or Register to comment.