question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can Sentry be initialized in the Android Application class? If so, update docs

See original GitHub issue

Currently, the documentation suggests that Sentry should be initialized in Activity.onCreate. However, if the application is ever started from a different Activity, this code will not be run. This code could be called from all of the activity entry points in the app but it’s easy to forget.

In theory, a preferable approach would be to initialize Sentry in Application.onCreate, which runs before any Activities start. Is there any problem with doing this? If not, I’d recommend updating the docs to officially support this configuration.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
omidrahacommented, Oct 15, 2019

@ninniuz I moved sentry.properties to <your-project>/<app-module>/src/main/resources/, And now there is no warning. Thank you so much.

@bruno-garcia Thank you for updating docs to configure Sentry in Application.

1reaction
bruno-garciacommented, Sep 24, 2019

We’ve update the docs to use Application instead. https://docs.sentry.io/clients/java/integrations/#initialization

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manual Initialization for Android - Sentry Documentation
Learn how to initialize the SDK manually when you need to provide additional configuration.
Read more >
Advanced Usage for Android - Sentry Documentation
Sentry uses the AndroidX libraries for detecting when the Application is either in the background or in the foreground. This is necessary for...
Read more >
Android - Docs - Sentry Documentation
The SDK can catch errors and crashes only after you've initialized it. So, we recommend calling SentryAndroid.init in the instance of the Application...
Read more >
Where to put `sentry.properties` file in Android Studio project?
/app/src/main/kotlin. I initialize Sentry on start of my app in class that extends android.app.Application like so: class ...
Read more >
Using Sentry - Expo Documentation
Sentry treats React Native as a first-class citizen and we have collaborated ... With expo-updates , release builds of both iOS and Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found