Android 提供 DSN 后哨兵未定义

Android Sentry is Undefined after providing DSN

我最近刚刚将 Sentry 添加到我的 Android 应用程序中。该应用程序是使用 Nativescript 构建的,但试图在 Google Play 商店上发布它。我在我的 build.gradle 文件中添加了 android 哨兵的实现,并在 Android 清单中添加了正确的元数据。

但是,每次我打开该应用程序时,它都会停止运行并出现此错误。

    E/JS: [SentryAngular - SentryErrorHandler] TypeError: Cannot read property 'Sentry' of undefined
    E/JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'Sentry' of undefined
        TypeError: Cannot read property 'Sentry' of undefined
            at Function.e.captureException (file:///data/user/0/com.rowforgellc.rowforge/files/app/vendor.js:35420:16)
            at Function.e.captureException (file:///data/user/0/com.rowforgellc.rowforge/files/app/bundle.js:4856:43)
            at e.<anonymous> (file:///data/user/0/com.rowforgellc.rowforge/files/app/bundle.js:3547:16)
            at file:///data/user/0/com.rowforgellc.rowforge/files/app/bundle.js:3536:14
            at Object.throw (file:///data/user/0/com.rowforgellc.rowforge/files/app/bundle.js:3538:40)
            at s (file:///data/user/0/com.rowforgellc.rowforge/files/app/bundle.js:3512:294)
            at e.invoke (file:///data/user/0/com.rowforgellc.rowforge/files/app/vendor.js:19256:137)
            at Object.onInvoke (file:///data/user/0/com.rowforgellc.rowforge/files/app/vendor.js:13832:10)
            at e.invoke (file:///data/user/0/com.rowforgellc.rowforge/files/app/vendor.js:19256:77)
            at t.run (file:...

这是我的AndroidManifest.xml

<application>
...
  <meta-data android:name="io.sentry.dsn" android:value="https://<DSN_HERE>.ingest.sentry.io/5339956" />

...
</application>

我不知道如何调试它。将不胜感激。

更新:已修复

刚刚让这个实际工作。我的 nativescript 部分已经使用 Javascript 处理 Sentry,但我不得不摆脱 Build.gradle 中的实现 SDK。似乎与 javascript SDK 冲突。

您已将 Sentry Android SDK 作为依赖项添加到 gradle 文件中。

这为您提供了 Android 的 Sentry SDK。您可以将它与 Java、Kotlin 甚至 C/C++ 一起使用,因为它支持 NDK。 它将捕获未捕获的异常、ANR、本地库中的本地崩溃等。

但此 SDK 不知道您在顶部的 JavaScript (NativeScript) 层。

Sentry 有一个针对 React Native 的包,它基于 JavaScript SDK 在 Android 和 iOS SDK 之上,但这无济于事你使用 NativeScript。

也就是说,我认为 Sentry 目前不支持 NativeScript,因此您需要调用本机层以通过本机 SDK 捕获错误,或者尝试创建类似于 React 的包装上面提到的原生SDK。