Skip to content

Crash for composable preview due to lack of DSN declaration in manifest  #2904

@hangduykhiem

Description

@hangduykhiem

Integration

sentry-android

Build System

Gradle

AGP Version

7.4.0

Proguard

Disabled

Version

6.28.0

Steps to Reproduce

  • Install Sentry with Gradle
  • Add DNS into Application Manifest
  • Write a simple compose preview, for example
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    MyApplicationTheme {
        Greeting("Android")
    }
}
  • Run this compose preview on the device, and not in the preview panel on Android Studio.

Expected Result

The preview runs normally and we can test our composables on a real device.

Actual Result

The PreviewActivity crashes with the following log

08-24 11:17:29.226  2992  2992 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread.installProvider(ActivityThread.java:8328)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:7828)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7577)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:226)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:313)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8757)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.Sentry.initConfigurations(Sentry.java:291)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.Sentry.init(Sentry.java:210)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.Sentry.init(Sentry.java:147)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:89)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:58)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:25)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2522)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2492)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:43)
08-24 11:17:29.226  2992  2992 E AndroidRuntime: 	at android.app.ActivityThread.installProvider(ActivityThread.java:8323)

By reading the log, it's quite obvious that the DNS is not declared in the manifest. However, we cannot override the PreviewActivity manifest, which is provided by compose-ui-tooling dependency. Whatever DNS declared in the main Manifest.xml is not read and applied to this manifest.

This seriously hampers our usage of Sentry, since our process requires running composable preview in the device to ensure our quality.

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions