perf: 优化 bugly 逻辑

This commit is contained in:
lisonge 2023-11-07 14:02:05 +08:00
parent a933360b6a
commit e4be8b6e60
5 changed files with 32 additions and 2 deletions

View File

@ -7,6 +7,9 @@ on:
branches:
- '**'
env:
BUGLY_TOKEN: ${{ secrets.BUGLY_TOKEN }}
jobs:
build:
if: ${{ !startsWith(github.event.head_commit.message, 'chore:') }}

View File

@ -5,6 +5,9 @@ on:
tags:
- v*
env:
BUGLY_TOKEN: ${{ secrets.BUGLY_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest

View File

@ -44,6 +44,9 @@ android {
).format(nowTime)
)
)
buildConfigField(
"String", "BUGLY_TOKEN", jsonStringOf(System.getenv("BUGLY_TOKEN"))
)
resourceConfigurations.addAll(listOf("zh", "en"))
ndk {

View File

@ -9,6 +9,7 @@ import com.tencent.mmkv.MMKV
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import li.songe.gkd.data.DeviceInfo
import li.songe.gkd.debug.clearHttpSubs
import li.songe.gkd.notif.initChannel
import li.songe.gkd.util.initAppState
@ -37,7 +38,27 @@ class App : Application() {
super.onCreate()
_app = this
CrashReport.initCrashReport(applicationContext, "d0ce46b353", false)
@Suppress("SENSELESS_COMPARISON") if (BuildConfig.BUGLY_TOKEN != null) {
CrashReport.setDeviceModel(this, DeviceInfo.instance.model)
CrashReport.setIsDevelopmentDevice(this, BuildConfig.DEBUG)
CrashReport.initCrashReport(applicationContext,
BuildConfig.BUGLY_TOKEN,
BuildConfig.DEBUG,
CrashReport.UserStrategy(this).apply {
setCrashHandleCallback(object : CrashReport.CrashHandleCallback() {
override fun onCrashHandleStart(
p0: Int,
p1: String?,
p2: String?,
p3: String?,
): MutableMap<String, String> {
LogUtils.d(p0, p1, p2, p3) // 将报错日志输出到本地
return super.onCrashHandleStart(p0, p1, p2, p3)
}
})
})
}
MMKV.initialize(this)
LogUtils.getConfig().apply {
setConsoleSwitch(BuildConfig.DEBUG)

View File

@ -80,7 +80,7 @@ dependencyResolutionManagement {
// https://github.com/Tencent/MMKV/blob/master/README_CN.md
library("tencent.mmkv", "com.tencent:mmkv:1.3.1")
// https://bugly.qq.com/docs/user-guide/instruction-manual-android/
library("tencent.bugly", "com.tencent.bugly:crashreport:4.1.9.2")
library("tencent.bugly", "com.tencent.bugly:crashreport:4.1.9.3")
// https://github.com/RikkaApps/HiddenApiRefinePlugin
val rikkaVersion = "4.4.0"