Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put `sentry.properties` file in Android Studio project?

Tags:

android

sentry

The documentation was not very helpful for me. Locations I've tried:

  • root folder (where gradle.properties and project's build.gradle files reside)
  • /app folder (where app's build.gradle file is localed)
  • /app/src/main/kotlin

I initialize Sentry on start of my app in class that extends android.app.Application like so:

    class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Sentry.init(AndroidSentryClientFactory(applicationContext))
    }
}

And then do a test capture in one of my methods:

Sentry.capture("This is a test capture using Sentry")

I also tried to specify the path to sentry.properties file explicitly in gradle.properties with no luck.

When I use Sentry.init() method that accepts DSN, it works, but this is not desired, because I do not want to check DSN into VCS.

I am aware of other methods of configuration, I just want to use sentry.properties though.

like image 774
Sevastyan Savanyuk Avatar asked Mar 26 '18 06:03

Sevastyan Savanyuk


2 Answers

There are in fact two different sentry.properties files.

  1. The sentry.properties that is used by the app at runtime to configure the DSN should be placed at /app/src/main/resources (documentation).

  2. The sentry.properties that is used at build time by Gradle to generate and upload ProGuard mappings to Sentry. This should be placed in the project root. (documentation). This is optional and only relevant for apps that use ProGuard.

like image 142
James Avatar answered Oct 20 '22 19:10

James


I found out that sentry.properties file should be placed in the root directory of the app.

  • For example if I have setup my project in XYZ folder then put sentry.properties in the same folder (its a same directory where you find AppName.iml, gradle.properties etc etc)
like image 35
Moulesh Avatar answered Oct 20 '22 20:10

Moulesh