Skip to content

Commit

Permalink
perf: 优化 bugly 逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 7, 2023
1 parent a933360 commit e4be8b6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/Build-Apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- '**'

env:
BUGLY_TOKEN: ${{ secrets.BUGLY_TOKEN }}

jobs:
build:
if: ${{ !startsWith(github.event.head_commit.message, 'chore:') }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/Build-Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- v*

env:
BUGLY_TOKEN: ${{ secrets.BUGLY_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ android {
).format(nowTime)
)
)
buildConfigField(
"String", "BUGLY_TOKEN", jsonStringOf(System.getenv("BUGLY_TOKEN"))
)

resourceConfigurations.addAll(listOf("zh", "en"))
ndk {
Expand Down
23 changes: 22 additions & 1 deletion app/src/main/java/li/songe/gkd/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e4be8b6

Please sign in to comment.