sentry官网网址:Android | Sentry Documentation
集成sentry的时候可能遇到这个异常: java.io.IOException: Cleartext HTTP traffic to XXX not permitted
因为从Android 6.0开始引入了对Https的推荐支持,与以往不同,Android P的系统上面默认所有Http的请求都被阻止了。
解决的办法简单来说可以通过在AnroidManifest.xml中的application显示设置:
<application android:usesCleartextTraffic="true">
本人集成是使用手动集成
1、先在自己的app的清单文件中加入一下代码:
<application>
<meta-data android:name="io.sentry.auto-init" android:value="false" />
</application>
2、在自己继承的Application中加入初始化代码如下:
SentryAndroid.init(this, options -> {
options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/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、dsn地址的@前面字符串的拼接的格式是examplepublickey=publickey:secretKey