getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.16k stars 435 forks source link

Sentry not recording Java exceptions w/AndroidManifest DSN, does w/calling SentryAndroid init #1116

Closed elliotmrodriguez closed 3 years ago

elliotmrodriguez commented 3 years ago

Platform:

IDE:

Build system:

Android Gradle Plugin:

Sentry Android Gradle Plugin:

Proguard/R8:

Platform installed with:

The version of the SDK: 3.2.0


I have the following issue:

Following the documentation for Android integration, I have observed that using DSN configuration in our AndroidManifest and watching the catch statement being executed, without error, does not cause exceptions to be recorded. However, using the manual instrumentation method with the same DSN does record exceptions.

Steps to reproduce:

Actual result:

Expected result:

marandaneto commented 3 years ago

hey @elliotmrodriguez thanks for raising this, could you please share a code snippet that exemplifies where you place the

<meta-data android:name="io.sentry.dsn" android:value="dsn..." /> tag?

elliotmrodriguez commented 3 years ago

Hi @marandaneto - thanks for your response.

Here's the line and surrounding lines:

 <application tools:replace="android:label"
        android:name="our.name.here"
        android:label="@string/APP_NAME"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:allowBackup="false"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        android:requestLegacyExternalStorage="true">
        <!-- adding android:usesCleartextTraffic="true" as most image urls are insecure http:// -->
        <meta-data android:name="io.sentry.dsn" android:value="https://ourdsn.ingest.sentry.io/123" />
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTask"
        android:label="@string/APP_NAME"
        android:screenOrientation="unspecified"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustPan">

let me know if you need more, thank you

marandaneto commented 3 years ago

@elliotmrodriguez it seems correct, although I can't reproduce it.

can you add this too and monitor logcat, ideally copy-paste logs so I can have a look at it?

<meta-data android:name="io.sentry.debug" android:value="true" />

also, do you have any other meta-data from Sentry or are you also instrumenting the code manually? something is fishy

the sources are also published, so if you add a breakpoint to any Sentry.captureException, you could see what's failing for example.

marandaneto commented 3 years ago

just out of curiosity, do you use this package? https://developer.android.com/reference/androidx/startup/package-summary

elliotmrodriguez commented 3 years ago

Hello @marandaneto, that package is not included in our app.

The only output from Logcat for Sentry after adding debugging:

2020-12-16 06:23:52.010 26101-26101/com.ebsco.ebscomobile D/Sentry: Auto-init: false
2020-12-16 06:23:52.011 26101-26101/com.ebsco.ebscomobile I/Sentry: Retrieving auto-init from AndroidManifest.xml

Nothing else is output to the logs.

We aren't using any other meta-data from Sentry; just the DSN at this point. Just to test, I added the same 2 meta-data elements to the debug manifest (dsn, debug) and the behavior does not change.

We are using @sentry/react-native version 2.1.0, and there is additional meta-data in that manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="io.sentry.react">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application>
        <meta-data android:name="io.sentry.auto-init" android:value="false" />
    </application>
</manifest>

but beyond gradle caches there are no other references.

elliotmrodriguez commented 3 years ago

@marandaneto

I re-read your suggestion and started debugging captureException and while I may not be doing this correctly it appears something is failing calling captureException from mainHub.

The stack frames show the following once the captureException method is invoked from Sentry.java:

Screen Shot 2020-12-16 at 7 07 38 AM

Android debugging is not my strength, so apologies if I am mis-reading anything here. The app continues to run if I resume past this.

marandaneto commented 3 years ago

@elliotmrodriguez ok I guess I got the culprit.

When you have a React Native app, you don't need to setup sentry-android as you are trying right now, actually, you don't need to do anything, sentry-react-native already bundles sentry-android under the hood and inits the SDK automatically for you.

you just need this: https://docs.sentry.io/platforms/react-native/

elliotmrodriguez commented 3 years ago

@marandaneto thank you.

In our use case, we have several custom native components for which we are trying to add Sentry crash reporting on the other side of the RN bridge. If I am understanding what you're saying re: the link to sentry-react-native, we don't need to explicitly configure this and can use the manual instrumentation method?

marandaneto commented 3 years ago

@elliotmrodriguez yes, just use Sentry.captureException on the native side (Android/iOS) and it should work ootb without any extra configuration.