Skip to content

sample-rate configuration from Manifest does not work #803

@cmorigaki

Description

@cmorigaki

Gradle Version

8.11.1

AGP Version

8.7.3

Code Minifier/Optimizer

None

Version

4.14.1

Sentry SDK Version

7.18.0

Steps to Reproduce

Use the Sentry auto-init feature:

  1. Apply sentry gradle plugin 4.14.1
  2. Set the sample-rate in the AndroidManifest.xml: <meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
  3. Run the appplication in debug
  4. Check Logcat filtering for "Sentry" word

The issue started from 4.14.0. The version 4.13.0 is working as expected. This PR is probably the cause of the issue.

Expected Result

Successfully init the App with the Sentry configuration. The logcat will show only io.sentry.auto-init read: true when filtering for "Sentry" word.

Actual Result

The Logcat shows io.sentry.auto-init read: true and then warning messages related to the manifest configuration of float values:

Key io.sentry.traces.sample-rate expected Integer but value was a java.lang.Float.  The default value -1 was returned.
Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Integer
    at android.os.BaseBundle.getInt(BaseBundle.java:1050)
    at io.sentry.android.core.ManifestMetadataReader.readDouble(ManifestMetadataReader.java:500)
    at io.sentry.android.core.ManifestMetadataReader.applyMetadata(ManifestMetadataReader.java:294)
    at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:109)
    at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:116)
    at io.sentry.android.core.SentryAndroid$$ExternalSyntheticLambda0.configure(D8$$SyntheticClass:0)
    at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:196)
    at io.sentry.Sentry.init(Sentry.java:166)
    at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:93)
    at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:64)
    at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:25)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2117)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2091)
    at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:43)
    at android.app.ActivityThread.installProvider(ActivityThread.java:7187)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6670)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6565)
    at android.app.ActivityThread.access$1400(ActivityThread.java:224)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7560)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Projects

Status

Done

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions