Android integrated sentry pit

Sentry official website URL: Android | Sentry Documentation

You may encounter this exception when integrating sentry: java.io.IOException: Cleartext HTTP traffic to XXX not permitted

Since Android 6.0 introduced the recommended support for Https, unlike before, all Http requests are blocked by default on the Android P system.
The solution is simply to display the settings through the application in AnroidManifest.xml:

<application android:usesCleartextTraffic="true">

My integration is to use manual integration

1. First add the following code to the manifest file of your app:    

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

2. Add the initialization code in the inherited Application as follows:

 SentryAndroid.init(this, options -> {
      options.setDsn("https://[email protected]/0");
      // Add a callback that will be used before the event is sent to Sentry.
      // With this callback, you can modify the event or, when returning null, also discard the event.
      options.setBeforeSend((event, hint) -> {
        if (SentryLevel.DEBUG.equals(event.getLevel()))
          return null;
        else
          return event;
      });
    });

3. The splicing format of the string in front of @ in the dsn address is examplepublickey=publickey:secretKey

Guess you like

Origin blog.csdn.net/weixin_44715716/article/details/122540342