2

I want to use Sentry for my Multiplatform Kotlin project.

Sentry for Kotlin Multiplatform

So I was trying to prepare the setup of Sentry with Kotlin Multiplatform. I was following the guide, made a mavenLocal() build etc. Now I wanted to add it to the project. However, when starting my (Android) project, even before starting the onCreate() of the Application I get a crash stating:

Unable to get provider io.sentry.android.core.SentryInitProvider: 
java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.

So to be clear this happens already when adding api("io.sentry:sentry-kotlin-multiplatform:0.0.1") to the dependencies. Long before the init call.

All I did was:

  1. Configure shared build.gradle.kts and add
 val commonMain by getting {
            dependencies {
                api("io.sentry:sentry-kotlin-multiplatform:0.0.1")
  1. Adding the sample configuration
fun initializeSentry(context: Context) {
    Sentry.init(context) { sentryOptions ->  setDsnHere... } 
}

and in the Android Application:

initializeSentry(this)

Then tried to run it. But I don't even get to the init call. The configuration should be reached and the initializeSentry(this) block executed. (I can accept if it fails there but I don't even get that far.)

Instead the app fails stating

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: xyz, PID: 23056
    java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
        at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
        ...

even before anything else. So the mere adding to the gradle file causes the crash already (even if the other code is commented out).

-------- Full Stack trace-------

java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
        at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744)
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7872)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

     Caused by: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
        at io.sentry.Sentry.initConfigurations(Sentry.java:201)
        at io.sentry.Sentry.init(Sentry.java:170)
        at io.sentry.Sentry.init(Sentry.java:118)
        at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
        at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:56)
        at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:27)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:2451)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:2421)
        at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:44)
        at android.app.ActivityThread.installProvider(ActivityThread.java:7462)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744) 
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.app.ActivityThread.main(ActivityThread.java:7872) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 

1 Answer 1

4

Turns out the manual had forgotten to mention the auto configuration.

Add this line to your Manifest:

<meta-data android:name="io.sentry.auto-init" android:value="false" />

and proceed with the tutorial.

For Reference:

https://github.com/getsentry/sentry-kotlin-multiplatform/issues/45

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.