Sitemap
Meyta Zenis Taliti

Meyta Zenis Taliti

I do programming, software engineering, and sometimes writing—mostly overthinking though. linkedin.com/in/meyta-taliti | github.com/mzennis

Press enter or click to view image in full size

[🔒] Secure Debug/Developer Mode

6 min readJun 9, 2025

--

You’ve stored keys within your app which you obtained them at runtime. But how can you verify that the app is using the correct keys especially without compromising security?

Sure, you’ve run your unit tests, your automated checks pass. But you still need human verification that the correct keys are being used in live environment.

The problem becomes more complex when you consider:

  • Displaying sensitive keys on screen violates security protocols;
  • Logging require technical setup and tool installation for non-technical team members; and,
  • You need a way to verify key usage without exposing sensitive information in production builds.

This is where a well-designed Debug/Developer mode becomes invaluable.

What is Debug/Developer mode?

Debug/Developer Mode is a special interface within an app that provides development and testing teams with essential runtime information while maintaining security boundaries.

Press enter or click to view image in full size
(Left) Debug mode available, (Right) No Debug mode available

We put together a simple demo showing the basics of implementing a debug/developer mode. Feel free to use it as a starting point for your project.

The first line of defense developer screens is controlling how users access them. Since these interfaces often expose sensitive functionality, you wouldn’t want random audience members wandering back there, right?

Implement hidden entry methods like complex gesture, multiple taps on specific UI elements, or simultaneous long press combinations that are unlikely to be accidentally triggered.

Exposing developer options by multiple taps on version numbers

Additionally, consider adding authentication layers such as PIN-based access, developer credential verification, or biometric authentication depending on the sensitivity of the operations.

Today’s journey splits into two approaches, each with its own advantages. Let’s explore both paths and help you choose the right one for your project.

Approach 1: Conditional Compilation with Build Variants

“Keep it simple, keep it secure”

In this approach we are using Android’s build system to conditionally include developer features only in debug builds.

Step 1: Enable BuildConfig Generation

First, we need to ensure our build system can distinguish between debug and release builds. If you’re using Android Gradle Plugin 8.0 or later, Google has made BuildConfig generation opt-in for performance reasons.

Add this to each module’s build.gradle file that needs BuildConfig:

android {
buildFeatures {
buildConfig = true
}
}

Step 2: The Simple Conditional Check

Now we can wrap our developer features in a simple but powerful conditional:

if (BuildConfig.DEBUG) { 
// Include debug activities and fragments
// Make sure you're importing the correct BuildConfig class
}

Step 3: The Elegant Source Set Solution

For a more sophisticated approach, we can use Android’s source sets to provide completely different implementations based on build type.

Project Structure:

app/src/
├── main/
│ ├── java/com/yourapp/
│ │ ├── MainActivity.kt
│ │ └── DevToolsManager.kt (interface)
├── debug/
│ ├── java/com/yourapp/
│ │ ├── DevToolsManagerImpl.kt (full implementation)
│ │ ├── DebugActivity.kt
└── release/
└── java/com/yourapp/
└── DevToolsManagerImpl.kt (stub implementation)

The Contract (Interface Definition):

// src/main/.../DevToolsManager.kt
interface DevToolsManager {
fun isAvailable(): Boolean
fun showDevTools(context: Context)
}

Debug Implementation (src/debug/.../DevToolsManagerImpl.kt)

// src/debug/.../DevToolsManagerImpl.kt
class DevToolsManagerImpl : DevToolsManager {
override fun isAvailable(): Boolean = true

override fun showDevTools(context: Context) {
context.startActivity(Intent(context, DebugActivity::class.java))
}
}

Release Implementation (src/release/.../DevToolsManagerImpl.kt)

// src/release/.../DevToolsManagerImpl.kt
class DevToolsManagerImpl : DevToolsManager {
override fun isAvailable(): Boolean = false

override fun showDevTools(context: Context) {
// No-op in release - silent and secure
}
}

Step 4: Bringing It All Together

In your MainActivity, the magic happen seamlessly. The same code works in both debug and release, but behaves completely differently:

class MainActivity : AppCompatActivity() {

private val devToolsManager: DevToolsManager = DevToolsManagerImpl()

private var versionTapCount = 0

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setupVersionTapListener()
}

private fun setupVersionTapListener() {
findViewById<TextView>(R.id.version_text).setOnClickListener {
if (devToolsManager.isAvailable()) {
versionTapCount++
if (versionTapCount >= 7) {
devToolsManager.showDevTools(this)
versionTapCount = 0
}
}
}
}
}

Step 5: Build Configuration Fine-Tuning

Complete the setup with proper build configuration:

android {

buildTypes {
debug {
applicationIdSuffix = ".debug" // ← OPTIONAL: Adds suffix to package name
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-debug.pro"
) // ← OPTIONAL: Debug-specific ProGuard
}
release {
minifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

Approach 2: Separate Module

“Isolation is the ultimate security”

Get Meyta Zenis Taliti’s stories in your inbox

Join Medium for free to get updates from this writer.

When you need more than conditional compilation, maybe because your developer tools are complex, have their own dependencies, or you want to complete architectural separation. This is where the separate module approach shines.

The Architecture

This approach treats developer tools as a completely separate module that can be easily excluded from release builds. Think of it as a detachable toolkit, present when you need it, absent when you don’t.

Project Structure

app/
├── src/main/...
├── build.gradle
developer-tools/
├── src/main/
│ ├── java/com/yourapp/devtools/
│ │ ├── DevToolsActivity.kt
│ └── AndroidManifest.xml
├── build.gradle
settings.gradle

Developer Tools Module (developer-tools/build.gradle)

// developer-tools/build.gradle
android {
compileSdk = 34

defaultConfig {
minSdk = 24
}
}

dependencies {
implementation project(':app')
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
// Debug-specific dependencies that won't bloat release builds
implementation 'com.facebook.flipper:flipper:0.182.0'
implementation 'com.squareup.leakcanary:leakcanary-android:2.12'
}

Conditional Module Integration

The key insight here is using Gradle’s dependency management to conditionally include the entire module:

// app/build.gradle
dependencies {
// Only include developer tools in debug builds
debugImplementation project(':developer-tools')

// Alternative approach with stub implementation:
// debugImplementation project(':developer-tools')
// releaseImplementation project(':developer-tools-stub') // Empty stub
}

The Reflection Bridge

Since the developer tools module won’t exist in release builds, we need a safe way to access it. Here we are using reflection, our bridge between worlds:

Developer Tools Entry Point

// In developer-tools module
class DevToolsLauncher {
companion object {
fun launch(context: Context) {
context.startActivity(Intent(context, DevToolsActivity::class.java))
}

fun isAvailable(): Boolean = true
}
}

Safe Access from Main App:

// In main app
class MainActivity : AppCompatActivity() {
private var tapCount = 0

private fun initializeDevTools() {
if (BuildConfig.DEBUG) {
try {
// Use reflection to avoid compile-time dependency
val devToolsClass = Class.forName("com.yourapp.devtools.DevToolsLauncher")
val launchMethod = devToolsClass.getMethod("launch", Context::class.java)

findViewById<View>(R.id.version_text).setOnClickListener {
tapCount++
if (tapCount >= 7) {
launchMethod.invoke(null, this)
tapCount = 0
}
}
} catch (e: Exception) {
// Dev tools not available
}
}
}
}

The Outcome: Security Without Compromise

Both approaches achieve the same critical goal: your release APK contains absolutely no traces of developer functionality while providing full debugging capabilities during development.

Okay, so when to choose each approach?

Choose Conditional Compilation when:

  • Your developer tools are relatively simple
  • You want minimal architectural overhead

Choose Separate Module when:

  • Your developer tools are complex with many dependencies
  • You want complete architectural separation
  • You need to share developer tools across multiple apps
  • You want the flexibility to version developer tools separately.

Once you’ve implemented your chosen approach, the quality of your developer tools becomes your next backlog. Here is user experience principles that you might want to add to your developer tools:

  • Clear Labeling: Visual distinction and awareness indicators
  • Confirmation Dialogs: Safety measures for destructive actions
  • Reset Options: Ways to restore defaults and clean slate functionality
  • Descriptive Help: Brief explanations for each developer option

and Lastly,

Recommended Developer Tools to Explore

I would recommend you to add this tool that can add your debugging capabilities:

  • Chuck: A simple in-app HTTP inspector that shows all network requests and responses directly within your app. It’s lightweight and perfect for quick network debugging without external tools.

Okay, this is last, the final word.

Security in software development is about creating systems that are secure by design, not by accident. But security without usability is just frustration in disguise. By combining robust security practices with thoughtful user experience design, you create developer tools that are not only safe but also genuinely helpful to your team’s workflow. And… catch you on the next one! 👋

Meyta Zenis Taliti
Meyta Zenis Taliti

Written by Meyta Zenis Taliti

I do programming, software engineering, and sometimes writing—mostly overthinking though. linkedin.com/in/meyta-taliti | github.com/mzennis