Skip to content

Commit b1c8333

Browse files
runningcodeclaude
andcommitted
feat(samples): Distinguish debug and release builds of the Android sample
Give the Android sample a `.debug` application id suffix and a "Sentry Sample Debug" launcher label so debug and release builds can be installed side by side and told apart on the home screen. Add a build type badge (DEBUG/RELEASE) under the Sentry logo in the navigation rail so the running build is visible inside the app too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6134075 commit b1c8333

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

sentry-samples/sentry-samples-android/build.gradle.kts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,29 @@ android {
111111

112112
buildTypes {
113113
getByName("debug") {
114-
addManifestPlaceholders(mapOf("sentryDebug" to true, "sentryEnvironment" to "debug"))
114+
// Suffix the id so debug and release builds can be installed side by side.
115+
applicationIdSuffix = ".debug"
116+
addManifestPlaceholders(
117+
mapOf(
118+
"sentryDebug" to true,
119+
"sentryEnvironment" to "debug",
120+
"appName" to "Sentry Sample Debug",
121+
)
122+
)
115123
}
116124
getByName("release") {
117125
isMinifyEnabled = true
118126
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
119127
signingConfig = signingConfigs.getByName("debug") // to be able to run release mode
120128
isShrinkResources = true
121129

122-
addManifestPlaceholders(mapOf("sentryDebug" to false, "sentryEnvironment" to "release"))
130+
addManifestPlaceholders(
131+
mapOf(
132+
"sentryDebug" to false,
133+
"sentryEnvironment" to "release",
134+
"appName" to "Sentry Sample",
135+
)
136+
)
123137
}
124138
}
125139

sentry-samples/sentry-samples-android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<application
2626
android:name=".MyApplication"
2727
android:icon="@mipmap/ic_launcher"
28-
android:label="@string/app_name"
28+
android:label="${appName}"
2929
android:networkSecurityConfig="@xml/network"
3030
android:roundIcon="@mipmap/ic_launcher_round"
3131
android:theme="@style/AppTheme"

sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MainActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ fun CategoryNavigationRail(
246246
.padding(12.dp)
247247
.rotate(rotation.value),
248248
)
249+
Spacer(Modifier.height(8.dp))
250+
Text(
251+
text = if (BuildConfig.DEBUG) "DEBUG" else "RELEASE",
252+
style = MaterialTheme.typography.labelSmall,
253+
fontWeight = FontWeight.Bold,
254+
color =
255+
if (BuildConfig.DEBUG) MaterialTheme.colorScheme.error
256+
else MaterialTheme.colorScheme.primary,
257+
)
249258
Spacer(Modifier.height(16.dp))
250259
Category.entries.forEach { category ->
251260
NavigationRailItem(

sentry-samples/sentry-samples-android/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<resources>
2-
<string name="app_name">Sentry sample</string>
32
<string name="crash_from_java">Crash from Java (UncaughtException)</string>
43
<string name="out_of_memory">Out of Memory (Mulithreaded)</string>
54
<string name="stack_overflow">Stack Overflow</string>

0 commit comments

Comments
 (0)