cursor text test hoj la la

cursor circle texty text

Privacy preferences
Always active
These items are required to enable basic website functionality.
These items are used to deliver advertising that is more relevant to you and your interests. They may also be used to limit the number of times you see an advertisement and measure the effectiveness of advertising campaigns.
These items allow the website to remember choices you make and provide enhanced, more personal features. For example, a website may provide you with a contact to local sales executive relevant to your area by storing data about your current location.
These items help the website operator understand how its website performs, how visitors interact with the site, and whether there may be technical issues.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Crash-Proofing Your Code: Setting Up Sentry on Android

April 4, 2024
Tomáš Dvořáček
Senior Android Developer

Welcome back! As promised, we are here with the second part of the Crash-proofing series. This time, we will show you how to set up Sentry for the Android platform and some nice-to-have stuff as a bonus.

Let's begin!

Create file inside your Android project’s root folder

Initial setup in Sentry Admin

These are a few things you need to do before implementing Sentry Android SDK.

  • Create a new project in Sentry. Give this project some appropriate name like your-project-android
  • Then go to Settings → Projects → Your new Project → General Settings
  • You should see the name of your project. This is your project_id. In, replace <project_id> with it
  • Then go to Organization settings → General Settings, copy your organisation_slug and replace <organisation_slug> inside
  • Then go to User and tokens and create new Token. You can add every permission to it for a start but its better to check every permission and decide for yourself what is needed.
  • Then copy your new auth token and replace <auth_token> with it inside can upload ProGuard mapping files for you and needs this auth token. Ignore this if you don’t care about ProGuard
  • Your should be filled now.
  • Then go to Settings → Projects → Your new Project → Client Key (DSN)
  • Get your DSN link and save it somewhere for now.
  • Now you can return to your Android Project

Adding sentry to project

A full tutorial is on this page. Sentry can set itself with a command, but if you prefer a manual approach or have problems, follow the instructions below or this page. Sentry will also give you a direct link for setup in Android Studio (

  1. Add this to your main module build.gradle
  1. Open your application class and initiate Sentry

Let’s explore what each line does:

This line applies the environment to the issue. If you use several build flavors like development and production, you can then easily filter specific flavors.

These lines set the percentage value of how many traces to log. 100% means everything is logged. It’s not recommended to collect everything in a production environment; however, e.g., on development, it’s a good thing since testers could find bugs. In our example, we set the percentage on the release version to 10%.

  1. Open your AndroidManifest.xml file inside your main module and insert this

If you don’t want to use CI/CD and just hardcode your DSN, replace ${sentryDsnUrl} with your collected DSN link.

  1. Open app’s build.gradle and setup DSN there as well
  1. Add Sentry gradle plugin to project

This code enables sentry gradle plugin. This prepares scripts for your convenience like uploading aab to sentry with proguard mapping files.

Nice things to know

Assign someone to new issue

Every issue in Sentry can be assigned to someone and you can do that manually or automatically with rules.

Manual approach
Automatic rules admin

Create Jira issue directly from Sentry

If you setup the Jira integration mentioned in the previous article, Sentry enables you to quickly and easily create Jira issues from the issue itself.

Discover page

Discover page let’s you quickly query in all yours collected data so you can answer analytics questions or analyse potential health issues in your project. You can use predefined queries or create, edit and delete your own queries. It’s really powerful tool but it’s limited only to Trial and Business Plan.

Pluggins for Sentry

Sentry for Android offers plugins which let’s you automatically collect more specific data. For example:

Some stuff like Android Fragments, okHttp events and logcat are already logged automatically from Sentry version 3.1.0.

In order to disable them, change the sentry config in the project’s build.gradle.

OkHttp plugin

Like said above, from Sentry 3.1.0, Sentry will automatically log OkHttp event via manipulating your final bytecode and inserting SentryOkHttpInterceptor. This will create breadcrumbs which would look like this:

If you use Sentry 3.11.0+, Sentry will also insert SentryOkHttpEventListener which will log even more data from http requests. Everything will be logged with logcat:

Thank you for diving into the second part of our series. If you have any questions, feel free to catch up or reach out.

What’s next?

Let’s continue the conversation.

Leave us your info so we can keep in touch about product development.

3D representation of discovery track, glass cubes and a metal arrow that spins around them.
Stay in touch
By clicking Submit you're confirming that you agree with our Privacy Policy.
Thank you! We will be in touch.
Oops! Something went wrong while submitting the form.
1 min read

Top 3 Reasons Why Startups Should Use an Agency for Development

Lukáš Stibor
1 min read

Stealth vs. Overhyped Marketing: Which is Better for Your Startup?

Lukáš Stibor
1 min read

Top AI Tools Our Project Managers Can’t Live Without

Michal Počuch
Head of PMO