发布初衷
前几天遇上这么个需求,一个安卓项目做完后,自己手测不能测全面所有功能,在实际运用中触发了几次app崩溃,但是无法通过联机监控的方式找错,所以试着配置sentry来捕获错误信息。开发环境下配置的很顺畅,直接走dsn链接就能直接上传成功错误信息。但是在打包产品apk时,sentry的文档配置信息过于模糊,导致处理打包问题卡了一个下午,这边写个文档希望能帮到遇见同样问题的人。
初始配置
- app/build.gradle
apply plugin: 'kotlin-android'
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
sentry {
// Disables or enables the automatic configuration of proguard
// for Sentry. This injects a default config for proguard so
// you don't need to do it manually.
autoProguardConfig false
// Enables or disables the automatic upload of mapping files
// during a build. If you disable this you'll need to manually
// upload the mapping files with sentry-cli when you do a release.
autoUpload true
}
dependencies {
implementation 'io.sentry:sentry-android:1.7.27'
implementation 'org.slf4j:slf4j-nop:1.7.25'
implementation 'org.jetbrains:annotations:16.0.2'
}
- build.gradle
buildscript {
dependencies {
classpath 'io.sentry:sentry-android-gradle-plugin:1.7.33'
}
}
- AndroidManifest.xml
dsn地址在sentry项目配置里能直接找到,sentry的项目新建
<?xml version="1.0" encoding="utf-8"