Skip to content

Commit 5efca71

Browse files
committed
上传mapping文件到bugly
1 parent 88e4079 commit 5efca71

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

app/build.gradle.kts

+47
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,50 @@ dependencies {
264264
val googleImplementation by configurations
265265
googleImplementation(libs.billingclient)
266266
}
267+
268+
// 上传mapping文件
269+
if (properties.getProperty("BUGLY_UPLOAD") == "1") {
270+
val uploadMapping by tasks.registering(Exec::class) {
271+
val jarFile = File(properties.getProperty("BUGLY_JAR") ?: "")
272+
if (!jarFile.exists()) {
273+
logger.warn("jarFile: ${jarFile.absolutePath} don't exist")
274+
return@registering
275+
}
276+
277+
val appId = properties.getProperty("BUGLY_APPID")
278+
val appKey = properties.getProperty("BUGLY_APPKEY")
279+
if (appId.isNullOrEmpty() || appKey.isNullOrEmpty()) {
280+
logger.warn("appId or appKey for bugly is invalid")
281+
return@registering
282+
}
283+
284+
val mappingFile =
285+
file("${project.layout.buildDirectory.asFile.get()}/outputs/mapping/nonGoogleWithUpdaterRelease/mapping.txt")
286+
val args = listOf(
287+
"-appid",
288+
appId,
289+
"-appkey",
290+
appKey,
291+
"-bundleid",
292+
android.defaultConfig.applicationId,
293+
"-version",
294+
android.defaultConfig.versionName,
295+
"-buildNo",
296+
android.defaultConfig.versionCode.toString(),
297+
"-platform",
298+
"Android",
299+
"-inputMapping",
300+
mappingFile.absolutePath
301+
)
302+
303+
commandLine = listOf("java", "-jar", jarFile.absolutePath) + args
304+
standardOutput = System.out
305+
errorOutput = System.out
306+
}
307+
308+
tasks.whenTaskAdded {
309+
if (name == "assembleNonGoogleWithUpdaterRelease") {
310+
finalizedBy(uploadMapping)
311+
}
312+
}
313+
}

app/src/main/java/remix/myplayer/service/VolumeController.kt

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package remix.myplayer.service
22

33
import android.os.CountDownTimer
4+
import android.os.DeadSystemException
45
import android.os.Handler
56
import androidx.annotation.FloatRange
67
import timber.log.Timber
@@ -46,6 +47,8 @@ class VolumeController(private val service: MusicService) {
4647
mediaPlayer.pause()
4748
} catch (e: IllegalStateException) {
4849
Timber.v(e)
50+
} catch (e: DeadSystemException) {
51+
Timber.v(e)
4952
}
5053
}
5154

0 commit comments

Comments
 (0)