Android

Already using Sentry for Android? Here are some recent highlights

We released Source Context, which shows snippets of code around the location of stack frames.

We just released a new Logcat integration, which automatically creates breadcrumbs for your android.util.Log.* calls.

Using Jetpack Compose? Measure composition and rendering time of your @Composable functions using our performance metrics for Jetpack Compose.

Let us know if you have feedback through GitHub issues.

On this page, we get you up and running with Sentry's SDK.

Don't already have an account and Sentry

projectRepresents your service in Sentry and allows you to scope events to a distinct application.
established? Head over to sentry.io, then return to this page.

Install

Sentry captures data by using an SDK within your application’s runtime.

We recommend installing the SDK through our installation wizard by running the following command inside your

projectRepresents your service in Sentry and allows you to scope events to a distinct application.
directory:

Copied
brew install getsentry/tools/sentry-wizard && sentry-wizard -i android

The wizard will prompt you to log in to Sentry. It'll then automatically do the following steps for you:

  • update your app's build.gradle file with the Sentry Gradle plugin and configure it
  • update your AndroidManifest.xml with the default Sentry configuration
  • create sentry.properties with an auth
    tokenIn search, a key-value pair or raw search term. Also, a value used for authorization.
    to upload proguard mappings (this file is automatically added to .gitignore)
  • add an example error to your app's Main Activity to verify your Sentry setup

After the wizard setup is completed, the SDK will automatically capture unhandled exceptions, and monitor performance. You can also manually capture errors.

Configure

Additional options can be found on our dedicated options page.

Here, you'll also be able to set context data, which includes data about the user, tags, or even arbitrary data, all of which will be added to every event sent to Sentry.

Verify

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

Copied
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import java.lang.Exception;
import io.sentry.Sentry;

public class MyActivity extends AppCompatActivity {
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
      throw new Exception("This is a test.");
    } catch (Exception e) {
      Sentry.captureException(e);
    }
  }
}

To view and resolve the recorded error, log into sentry.io and open your

projectRepresents your service in Sentry and allows you to scope events to a distinct application.
. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").