How do I obtain crash-data from my Android application?
Asked Answered
A

30

769

How can I get crash data (stack traces at least) from my Android application? At least when working on my own device being retrieved by cable, but ideally from any instance of my application running on the wild so that I can improve it and make it more solid.

Apartment answered 2/3, 2009 at 7:17 Comment(5)
Check this out: github.com/tomquist/Android-Error-ReporterTheogony
I see that this sends the report to a remote server. Can it also log the exception to a local file?Perigordian
Application Crash Report for Android code.google.com/p/acraBasso
This one looks to be the more robust, what about if the reporting fails to upload after all the retries, can it then log it file or sqlite db?Bimetallism
Did you try Firebase Crashlytics?Athenaathenaeum
H
360

You might try the ACRA (Application Crash Report for Android) library:

ACRA is a library enabling Android Application to automatically post their crash reports to a GoogleDoc form. It is targetted to android applications developers to help them get data from their applications when they crash or behave erroneously.

It's easy to install in your app, highly configurable and don't require you to host a server script anywhere... reports are sent to a Google Doc spreadsheet !

Hemolysis answered 18/5, 2010 at 8:52 Comment(9)
This is easy to setup and use. Recommended for pre-market place usage, and even possibly after.Toot
Started using it and it's incommensurably better than the error reporting in Flurry I had before or the homemade one I started with. So far, I'm stoked on "acra".Tarbox
The big advantage of acra is the possibility to use Google APIs to easily analyse and visualize the data, see jberkel.github.com/sms-backup-plus/acra-analysis for an example on how to do this.Crabtree
Seems very unstable for me. The ACRA itself crashed and sent crash report about itself not the related app crash. -1Forelimb
Reports content is detailed here: code.google.com/p/acra/wiki/ReportContent . You can trigger reports without a crash using the handleSilentException() method code.google.com/p/acra/wiki/… . You can collect more data in the CUSTOM_DATA field and also implement a custom ReportSender to get additional data and/or send them to your own server.Hemolysis
From ACRA home: "A crash reporting feature for android apps is native since Android 2.2 (FroYo) but only available through the official Android Market (and with limited data)." What do they mean with "native"? Has Android since 2.2 already reporting mechanism? Which one?Sanyu
Google Docs as a backend is not supported any moreLineate
From ACRA home if you use the Toast, Status bar notification or direct dialog modes, the "force close" dialog is not displayed anymore and devices where the system native reporting feature is enabled do not offer the user to send an additional report. Is it means when my application crashed then no more "force close" dialog? Is my application still running?Stringhalt
A nice tutorial on how to set up ACRA: toptal.com/android/…Chlorophyll
B
314

For sample applications and debugging purposes, I use a simple solution that allows me to write the stacktrace to the sd card of the device and/or upload it to a server. This solution has been inspired by Project android-remote-stacktrace (specifically, the save-to-device and upload-to-server parts) and I think it solves the problem mentioned by Soonil. It's not optimal, but it works and you can improve it if you want to use it in a production application. If you decide to upload the stacktraces to the server, you can use a php script (index.php) to view them. If you're interested, you can find all the sources below - one java class for your application and two optional php scrips for the server hosting the uploaded stacktraces.

In a Context (e.g. the main Activity), call

if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
    Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(
            "/sdcard/<desired_local_path>", "http://<desired_url>/upload.php"));
}

CustomExceptionHandler

public class CustomExceptionHandler implements UncaughtExceptionHandler {

    private UncaughtExceptionHandler defaultUEH;

    private String localPath;

    private String url;

    /* 
     * if any of the parameters is null, the respective functionality 
     * will not be used 
     */
    public CustomExceptionHandler(String localPath, String url) {
        this.localPath = localPath;
        this.url = url;
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
    }

    public void uncaughtException(Thread t, Throwable e) {
        String timestamp = TimestampFormatter.getInstance().getTimestamp();
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        e.printStackTrace(printWriter);
        String stacktrace = result.toString();
        printWriter.close();
        String filename = timestamp + ".stacktrace";

        if (localPath != null) {
            writeToFile(stacktrace, filename);
        }
        if (url != null) {
            sendToServer(stacktrace, filename);
        }

        defaultUEH.uncaughtException(t, e);
    }

    private void writeToFile(String stacktrace, String filename) {
        try {
            BufferedWriter bos = new BufferedWriter(new FileWriter(
                    localPath + "/" + filename));
            bos.write(stacktrace);
            bos.flush();
            bos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void sendToServer(String stacktrace, String filename) {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("filename", filename));
        nvps.add(new BasicNameValuePair("stacktrace", stacktrace));
        try {
            httpPost.setEntity(
                    new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
            httpClient.execute(httpPost);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

upload.php

<?php
    $filename = isset($_POST['filename']) ? $_POST['filename'] : "";
    $message = isset($_POST['stacktrace']) ? $_POST['stacktrace'] : "";
    if (!ereg('^[-a-zA-Z0-9_. ]+$', $filename) || $message == ""){
        die("This script is used to log debug data. Please send the "
                . "logging message and a filename as POST variables.");
    }
    file_put_contents($filename, $message . "\n", FILE_APPEND);
?>

index.php

<?php
    $myDirectory = opendir(".");
    while($entryName = readdir($myDirectory)) {
        $dirArray[] = $entryName;
    }
    closedir($myDirectory);
    $indexCount = count($dirArray);
    sort($dirArray);
    print("<TABLE border=1 cellpadding=5 cellspacing=0 \n");
    print("<TR><TH>Filename</TH><TH>Filetype</th><th>Filesize</TH></TR>\n");
    for($index=0; $index < $indexCount; $index++) {
        if ((substr("$dirArray[$index]", 0, 1) != ".") 
                && (strrpos("$dirArray[$index]", ".stacktrace") != false)){ 
            print("<TR><TD>");
            print("<a href=\"$dirArray[$index]\">$dirArray[$index]</a>");
            print("</TD><TD>");
            print(filetype($dirArray[$index]));
            print("</TD><TD>");
            print(filesize($dirArray[$index]));
            print("</TD></TR>\n");
        }
    }
    print("</TABLE>\n");
?>
Block answered 16/4, 2009 at 8:0 Comment(7)
I think this will cause legal issues in some states / countriesOrv
NOTE: HttpPost httpPost = new HttpPost(url); must be in an async task (or handler... a separate thread) now if you are targeting Honeycomb or laterSink
@Joset, what sort of legal issues, and why?Frizzell
@Frizzell Legal issues (maybe) because you are sending sensitive device information without the user's consent by using the Send-to-Server feature of this code.Houlberg
The defaultExceptionHandler seems to persist across Activity recreation. I updated the answer to only set the default if a custom handler isn't already set. Without it, each handler holds and calls the previous one, all the way to the original one. This causes issues with duplicate logging as well as memory leak issues.Internuncial
Till Android 6 the above solution works fine. Since Android 7 nougat no information is send. How come?Pardon
What a quick way to get hacked :DNoon
E
60

You can also try [BugSense] Reason: Spam Redirect to another url. BugSense collects and analyzed all crash reports and gives you meaningful and visual reports. It's free and it's only 1 line of code in order to integrate.

Disclaimer: I am a co-founder

Expanse answered 2/3, 2009 at 7:17 Comment(5)
I've tried BugSense and its awesome. Simple and fresh UI, very quick too. No stupid feature bloat. Easy to see the most frequent crashes and also to dig into the stacktrace.Selfabasement
We lately do much more than just Crash reporting but this is not the right place to talk new features etc.Expanse
Tried it. Errors worked though stacktrace is not too complete, real-time crash data didn't come through. Debug mode didn't work. I went down the initialize-once route from Application class though (which is what makes sense for most cases). BugSense has an amazing dashboard, such a shame that for some reason crash reports don't work and symbolication is not in the free tier. Took me 5 minutes to install GetSentry and it just worked out of the box for Android with this general purpose client: github.com/joshdholtz/Sentry-AndroidPutsch
BugSense is simple and easy to integrate. BUT IT IS TOO EXPENSIVE. We can achieve the same bug sense functionalities using Flurry analytics and Parse. Both of them are free and easy to integrate.Crouton
BugSense was ended its product life in 2021. Solutions from sentry.io and Splunk Real User Monitoring (RUM) might be good alternatives.Sedimentation
M
45

In Android 2.2 it's now possible to automatically get Crash Reports from Android Market Applications:

New bug reporting feature for Android Market apps enables developers to receive crash and freeze reports from their users. The reports will be available when they log into their publisher account.

http://developer.android.com/sdk/android-2.2-highlights.html

Mcnabb answered 28/5, 2010 at 10:34 Comment(7)
I think it is not just 2.2 but simply a new market feature google offers. I got a crashreport some days ago and there shouldn't be a froyo device out there using my app.Solus
@Solus Are you sure? there are already releases of Froyo for Nexus One, without counting the Googlers who've been running Froyo for a while.Omnifarious
At least there must been an update in the version on the phone, even its just another revision, but how should this work elsewise?Mcnabb
I don't know if the reports got send to google before. The report is somewhat strange because google shows a UI for sending in their videos and that has to be a change in the OS and not only the market. But it says: Platforms 1 reports reports/week and the droid shouldn't be on froyo.Solus
The "Report" button code has been in the AOSP for a while, and Romain Guy (vaguely) answered a question about it on here a couple of months ago.Kyles
See also <android-developers.blogspot.com.au/2010/05/…>Shabbir
Current link: android-developers.blogspot.com/2010/05/…Combe
C
32

It is possible to handle these exceptions with Thread.setDefaultUncaughtExceptionHandler(), however this appears to mess with Android's method of handling exceptions. I attempted to use a handler of this nature:

private class ExceptionHandler implements Thread.UncaughtExceptionHandler {
    @Override
    public void uncaughtException(Thread thread, Throwable ex){
        Log.e(Constants.TAG, "uncaught_exception_handler: uncaught exception in thread " + thread.getName(), ex);

        //hack to rethrow unchecked exceptions
        if(ex instanceof RuntimeException)
            throw (RuntimeException)ex;
        if(ex instanceof Error)
            throw (Error)ex;

        //this should really never happen
        Log.e(Constants.TAG, "uncaught_exception handler: unable to rethrow checked exception");
    }
}

However, even with rethrowing the exceptions, I was unable to get the desired behavior, ie logging the exception while still allowing Android to shutdown the component it had happened it, so I gave up on it after a while.

Canaday answered 18/3, 2009 at 17:24 Comment(5)
Why are you only re-throwing unchecked exceptions? It seems to me you should re-throw all exceptions.Written
Looks like someone succeeded with your approach: jyro.blogspot.com/2009/09/crash-report-for-android-app.htmlWritten
The trick is to get the previous default UncaughtExceptionHandler and handle the exception to that object after you finished reporting the exception.Theogony
Is Constants.TAG part of the Android framework? First time seeing it. Can't seem to find it.Graff
@HarounHajem We need to define our own.Fatality
S
25

I see that the question is too old, and hope my answer is helpful for others having the same issue...

Give Crashlytics a try. It will give indepth insight into all the crashes on all the devices having your application and send a notification to you through email..And the best part is its completely free to use..

Showbread answered 2/3, 2009 at 7:17 Comment(0)
H
22

Ok, well I looked at the provided samples from rrainn and Soonil, and I found a solution that does not mess up error handling.

I modified the CustomExceptionHandler so it stores the original UncaughtExceptionHandler from the Thread we associate the new one. At the end of the new "uncaughtException"- Method I just call the old function using the stored UncaughtExceptionHandler.

In the DefaultExceptionHandler class you need sth. like this:

public class DefaultExceptionHandler implements UncaughtExceptionHandler{
  private UncaughtExceptionHandler mDefaultExceptionHandler;

  //constructor
  public DefaultExceptionHandler(UncaughtExceptionHandler pDefaultExceptionHandler)
  {
       mDefaultExceptionHandler= pDefaultExceptionHandler;
  }
  public void uncaughtException(Thread t, Throwable e) {       
        //do some action like writing to file or upload somewhere         

        //call original handler  
        mStandardEH.uncaughtException(t, e);        

        // cleanup, don't know if really required
        t.getThreadGroup().destroy();
  }
}

With that modification on the code at http://code.google.com/p/android-remote-stacktrace you have a good working base for logging in the field to your webserver or to sd-card.

Hendeca answered 13/5, 2009 at 21:51 Comment(0)
B
21

Google Play Developers Console actually gives you the Stack traces from those apps that have crashed and had sent the reports, it has also a very good charts to help you see the information, see example below:

enter image description here

Bilharziasis answered 2/3, 2009 at 7:17 Comment(4)
How do you have the users send the reports or how does that work exactly if your app is not in the play store, can you do it for testing purposes?Maribelmaribelle
Do you know that is there any open source Android project which public their crash reports?Mild
Please note, this will show only the crashes, ANR that users chose to reportSire
Yeah indeed, anyway when you have a big user base you have a lot of possibilities of all crashes being reported, and also crashes and ANR's reported here will be the most important ones, because people will report them more times, so that way you can filter and fix them in that priority (more reports = more important bug) while (no report = not that critical bug).Bilharziasis
A
18

I've been using Crittercism for my Android and iOS apps -- heard about them on techcrunch. Pretty happy with them so far!

Anelace answered 2/3, 2009 at 7:17 Comment(2)
FYI: crash reports from the NDK side are not part of the basic plan, and come under "Extended Crash Reporting". See: crittercism.com/pricingWirephoto
I just tested the NDK reporting on Twitter's Fabric.io Crashlytics... pretty great (on day 1 of use), it required an extra step when I release to put the mapping up into their system so stack traces look good, but it nailed the NDK error I used to test (made an "abort();" call strategically throughout the c++ and it provided a stack trace for testing.Atahualpa
D
15

I made my own version here : http://androidblogger.blogspot.com/2009/12/how-to-improve-your-application-crash.html

It's basically the same thing, but I'm using a mail rather than a http connexion to send the report, and, more important, I added some informations like application version, OS version, Phone model, or avalaible memory to my report...

Deina answered 15/12, 2009 at 0:25 Comment(0)
P
11

use this to catch the exception details:

String stackTrace = Log.getStackTraceString(exception); 

store this in database and maintain the log.

Portiere answered 2/3, 2009 at 7:17 Comment(1)
How to access that Data base , will you give me any example. please if you can. thanks in advacneDallon
B
8

Now a days Firebase Crash reports are very popular and easier to use. Please refer following link for more information: Firebase Crash Reporting

Hope it will help you.

Breechcloth answered 2/3, 2009 at 7:17 Comment(0)
F
8

You can also use a whole (simple) service for it rather than only library. Our company just released a service just for that: http://apphance.com.

It has a simple .jar library (for Android) that you add and integrate in 5 minutes and then the library gathers not only crash information but also logs from running application, as well as it lets your testers report problems straight from device - including the whole context (device rotation, whether it is connected to a wifi or not and more). You can look at the logs using a very nice and useful web panel, where you can track sessions with your application, crashes, logs, statistics and more. The service is in closed beta test phase now, but you can request access and we give it to you very quickly.

Disclaimer: I am CTO of Polidea, and co-creator of the service.

Falgout answered 2/3, 2009 at 7:17 Comment(0)
R
7

There is this android library called Sherlock. It gives you the full report of crash along with device and application information. Whenever a crash occurs, it displays a notification in the notification bar and on clicking of the notification, it opens the crash details. You can also share crash details with others via email or other sharing options.

Installation

android {
    dataBinding {
      enabled = true
    }
}

compile('com.github.ajitsing:sherlock:1.0.0@aar') {
    transitive = true
}

Demo

enter image description here

Recessional answered 2/3, 2009 at 7:17 Comment(0)
R
7

Thanks resources present in Stackoverflow in helping me to find this answer.

You can find your remotely Android crash reports directly into your email. remmember you have to put your email inside CustomExceptionHandler class.

public static String sendErrorLogsTo = "[email protected]" ;

Steps required :

1st) in onCreate of your activity use this section of your code.

    if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
    }   

2nd) use this overridden version of CustomExceptionHandler class of ( rrainn ), according to my phpscript.

package com.vxmobilecomm.activity;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
import android.util.Log;

public class CustomExceptionHandler implements UncaughtExceptionHandler {

    private UncaughtExceptionHandler defaultUEH;
    public static String sendErrorLogsTo = "[email protected]" ;

    Activity activity;

    public CustomExceptionHandler(Activity activity) {
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
        this.activity = activity;
    }

    public void uncaughtException(Thread t, Throwable e) {

        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        e.printStackTrace(printWriter);
        String stacktrace = result.toString();
        printWriter.close();
        String filename = "error" + System.nanoTime() + ".stacktrace";

        Log.e("Hi", "url != null");
        sendToServer(stacktrace, filename);

        StackTraceElement[] arr = e.getStackTrace();
        String report = e.toString() + "\n\n";
        report += "--------- Stack trace ---------\n\n";
        for (int i = 0; i < arr.length; i++) {
            report += "    " + arr[i].toString() + "\n";
        }
        report += "-------------------------------\n\n";

        report += "--------- Cause ---------\n\n";
        Throwable cause = e.getCause();
        if (cause != null) {
            report += cause.toString() + "\n\n";
            arr = cause.getStackTrace();
            for (int i = 0; i < arr.length; i++) {
                report += "    " + arr[i].toString() + "\n";
            }
        }
        report += "-------------------------------\n\n";

        defaultUEH.uncaughtException(t, e);
    }

    private void sendToServer(String stacktrace, String filename) {
        AsyncTaskClass async = new AsyncTaskClass(stacktrace, filename,
                getAppLable(activity));
        async.execute("");
    }

    public String getAppLable(Context pContext) {
        PackageManager lPackageManager = pContext.getPackageManager();
        ApplicationInfo lApplicationInfo = null;
        try {
            lApplicationInfo = lPackageManager.getApplicationInfo(
                    pContext.getApplicationInfo().packageName, 0);
        } catch (final NameNotFoundException e) {
        }
        return (String) (lApplicationInfo != null ? lPackageManager
                .getApplicationLabel(lApplicationInfo) : "Unknown");
    }

    public class AsyncTaskClass extends AsyncTask<String, String, InputStream> {
        InputStream is = null;
        String stacktrace;
        final String filename;
        String applicationName;

        AsyncTaskClass(final String stacktrace, final String filename,
                String applicationName) {
            this.applicationName = applicationName;
            this.stacktrace = stacktrace;
            this.filename = filename;
        }

        @Override
        protected InputStream doInBackground(String... params) 
        { 
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(
                    "http://suo-yang.com/books/sendErrorLog/sendErrorLogs.php?");

            Log.i("Error", stacktrace);

            try {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
                        6);

                nameValuePairs.add(new BasicNameValuePair("data", stacktrace));
                nameValuePairs.add(new BasicNameValuePair("to",sendErrorLogsTo));
                nameValuePairs.add(new BasicNameValuePair("subject",applicationName));

                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                HttpResponse response = httpclient.execute(httppost);

                HttpEntity entity1 = response.getEntity();

                BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(
                        entity1);

                is = bufHttpEntity.getContent();

            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return is;
        }

        @Override
        protected void onPostExecute(InputStream result) {
            super.onPostExecute(result);

            Log.e("Stream Data", getStringFromInputStream(is));
        }
    }

    // convert InputStream to String
    private static String getStringFromInputStream(InputStream is) {

        BufferedReader br = null;
        StringBuilder sb = new StringBuilder();

        String line;
        try {

            br = new BufferedReader(new InputStreamReader(is));
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        return sb.toString();

    }
}
Ragamuffin answered 2/3, 2009 at 7:17 Comment(0)
L
6

While many of the answers on this page are useful, it is easy for them to become out of date. The AppBrain website aggregates statistics which allow you to find the most popular crash reporting solution that is current:

Android crash reporting libraries

app brain website

You can see that at the time of posting this picture, Crashlytics is used in 5.24% of apps and 12.38% of installs.

Livable answered 2/3, 2009 at 7:17 Comment(0)
S
6

Google Firebase is Google's latest(2016) way to provide you with crash/error data on your phone. Include it in your build.gradle file :

compile 'com.google.firebase:firebase-crash:9.0.0'

Fatal crashes are logged automatically without requiring user input and you can also log non-fatal crashes or other events like so :

try
{

}
catch(Exception ex)
{
    FirebaseCrash.report(new Exception(ex.toString()));
}
Smasher answered 2/8, 2016 at 7:47 Comment(0)
N
5

There is a tool called fabric, this is a crash analytic tool, which will allow you to get crash reports , when application deployed live and during development. Adding this tool to your application was simple as well.. When your application crash that report of the crash can be viewed from your fabric.io dashboard . thw report was catched automatically.it won't ask user for permission. Whether he/she want to send the bug/crash report. And this is completely free... https://get.fabric.io/

Niblick answered 2/3, 2009 at 7:17 Comment(0)
T
5

This is very brute, but it is possible to run logcat anywhere, so a quick and dirty hack is to add to any catch block getRuntime().exec("logcat >> /sdcard/logcat.log");

Transfiguration answered 2/3, 2009 at 7:17 Comment(1)
This would give the log output of all the apps. Filtering by the App tagname might be okay but don't think this would be a good way to go as the entries might be cummulative. Clearing the logcat output after each write might solve that issue though.Shreveport
L
4

We use our home-grown system inside the company and it serves us very well. It's an android library that send crash reports to server and server that receives reports and makes some analytics. Server groups exceptions by exception name, stacktrace, message. It helps to identify most critical issues that need to be fixed. Our service is in public beta now so everyone can try it. You can create account at http://watchcat.co or you can just take a look how it works using demo access http://watchcat.co/reports/index.php?demo.

Likeness answered 2/3, 2009 at 7:17 Comment(0)
M
3

I found one more great web application to track the error reports.

https://mint.splunk.com/

Small number of steps to configure.

  1. Login or sign up and configure using the above link. Once you done creating a application they will provide a line to configure like below.
Mint.initAndStartSession(YourActivity.this, "api_key");
  1. Add the following in the application's build.gradl.
android {
...
    repositories {
        maven { url "https://mint.splunk.com/gradle/"}
    }
...
}

dependencies {
...
    compile "com.splunk.mint:mint:4.4.0"
...
}
  1. Add the code which we copied above and add it to every activity.

    Mint.initAndStartSession(YourActivity.this, "api_key");

That's it. You login and go to you application dashboard, you will get all the error reports.

Hope it helps someone.

Minacious answered 2/3, 2009 at 7:17 Comment(1)
How much does this cost?Baynebridge
M
3

If you want answers immediately you can use logcat

$adb shell logcat -f /sdcard/logoutput.txt *:E

If there's too much junk in your log right now, try clearing it first.

$adb shell logcat -c

Then try running your app then logcat again.

Manstopper answered 2/3, 2009 at 7:17 Comment(1)
Doesn't this still require that you hook up the device to a PC (eg with a cable)?Ochre
C
2

For an alternate crash reporting/exception tracking service check out Raygun.io - it's got a bunch of nice logic for handling Android crashes, including decent user experience when plugging it in to your app (two lines of code in your main Activity and a few lines of XML pasted into AndroidManifest).

When your app crashes, it'll automatically grab the stack trace, environment data for hard/software, user tracking info, any custom data you specify etc. It posts it to the API asynchronously so no blocking of the UI thread, and caches it to disk if there's no network available.

Disclaimer: I built the Android provider :)

Coffman answered 2/3, 2009 at 7:17 Comment(0)
P
1

Google changed how much crash reports you actually get. Previously you only got manual reported bug reports.

Since the last developer conference and the introducation of Android Vitals you also get crash reports from users which have enabled to share diagnostics data.

You'll see all crashes collected from Android devices whose users have opted in to automatically share usage and diagnostics data. Data is available for the previous two months.

View crashes & application not responding (ANR) errors

Putput answered 2/3, 2009 at 7:17 Comment(1)
logcat is saying there is an output crash dump file in /data/user/0/com.<myappname>/cache/WebView/Crash Report/<GUUID>.dmp, but the device isn't rooted and I can't figure out how to access this file!Caracalla
D
1

I'm one of the founders of Bugsnag which we designed for exactly this purpose. Bugsnag automatically captures unhandled exceptions in Android apps and sends them to our dashboard, where you can prioritize fixes and dive into diagnostic information.

Here are some important things to consider when selecting or building a crash reporting system, along with some code snippets:

  • Detects unhandled exceptions automatically (example code)
  • Collects diagnostic data such as memory usage, device info, etc (example code)
  • Effectively groups crashes together by root cause
  • Allows you to track actions the user took before each crash to help reproduce (example code)

If you want to see some best practices around crash handling/reporting on Android you can check out the full source code for Bugsnag's crash reporting library which is fully open source, feel free to tear this apart and use it in your own applications!

Disadvantage answered 2/3, 2009 at 7:17 Comment(0)
L
1

Late to the party, I support and believe ACRA is the best option among all. Its easy to setup and configure. I have created a detailed guide with inputs from all over to fetch the crash report using ACRA and mail the same to my email address using MandrillAp.

Link to post: https://androidician.wordpress.com/2015/03/29/sending-crash-reports-with-acra-over-email-using-mandrill/

Link to sample project on github: https://github.com/ayushhgoyal/AcraSample

Lxx answered 2/3, 2009 at 7:17 Comment(0)
L
1

Just Started to use ACRA https://github.com/ACRA/acra using Google Forms as backend and it's very easy to setup & use, it's the default.

BUT Sending reports to Google Forms are going to be deprecated (then removed): https://plus.google.com/118444843928759726538/posts/GTTgsrEQdN6 https://github.com/ACRA/acra/wiki/Notice-on-Google-Form-Spreadsheet-usage

Anyway it's possible to define your own sender https://github.com/ACRA/acra/wiki/AdvancedUsage#wiki-Implementing_your_own_sender you can give a try to email sender for example.

With minimum effort it's possible to send reports to bugsense: http://www.bugsense.com/docs/android#acra

NB The bugsense free account is limited to 500 report/month

Landfall answered 2/3, 2009 at 7:17 Comment(0)
S
0

You can do this directly in Android Studio. Just connect your phone, run the app, let it crash and you can view the stacktrace directly in Android Studio.

Shannan answered 2/3, 2009 at 7:17 Comment(0)
L
0

If your app is being downloaded by other people and crashing on remote devices, you may want to look into an Android error reporting library (referenced in this SO post). If it's just on your own local device, you can use LogCat. Even if the device wasn't connected to a host machine when the crash occurred, connected the device and issuing an adb logcat command will download the entire logcat history (at least to the extent that it is buffered which is usually a loooot of log data, it's just not infinite). Do either of those options answer your question? If not can you attempt to clarify what you're looking for a bit more?

Leak answered 2/3, 2009 at 7:17 Comment(0)
G
0

Flurry analytics gives you crash info, hardware model, android version and live app usage stats. In the new SDK they seem to provide more detailed crash info http://www.flurry.com/flurry-crash-analytics.html.

Goldsworthy answered 2/3, 2009 at 7:17 Comment(1)
Flurry is limited to only so many characters and gives you no lines numbers or similar.Sink

© 2022 - 2024 — McMap. All rights reserved.