Android SDK
Integrate SecureInspector into your Android app for privacy-first debugging with end-to-end encryption.
1 Installation
Add the SecureInspector dependency to your app's build.gradle.kts:
dependencies {
implementation("com.secureinspector:sdk:1.0.0")
}
Or if using Groovy build.gradle:
dependencies {
implementation 'com.secureinspector:sdk:1.0.0'
}
2 Initialization
Initialize the SDK in your Application class:
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
SecureInspector.init(
application = this,
config = SecureInspectorConfig.Builder(
serverUrl = "https://your-server.com",
apiKey = "your-api-key",
encryptionKey = "your-base64-encryption-key"
).build()
)
}
}
Using Password Instead of Key
You can use a password instead of a pre-generated encryption key:
// Password-based initialization (PBKDF2 key derivation)
val config = SecureInspectorConfig.Builder.withPassword(
serverUrl = "https://your-server.com",
apiKey = "your-api-key",
password = "your-secure-password"
).build()
3 HTTP Capture
Add the interceptor to your OkHttpClient to capture all HTTP traffic:
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(SecureInspector.getInterceptor())
.build()
// Use with Retrofit
val retrofit = Retrofit.Builder()
.baseUrl("https://api.example.com/")
.client(okHttpClient)
.build()
4 User Identification
Set the user ID after login to associate captures with specific users:
// After successful login
SecureInspector.setUserId("user@example.com")
// On logout
SecureInspector.clearUserId()
Important
The SDK only captures data when a debug session is active in the dashboard AND the user ID matches the session target.
5 Crash Handling
Crash handling is enabled by default. The SDK captures uncaught exceptions with full context:
- Full stack trace
- Device information (model, OS version, memory)
- Current screen name
- Breadcrumbs (last 30 user actions)
- Recent HTTP calls
Crashes are stored locally and sent on next app launch.
6 Error Capture
Manually capture handled exceptions in your try/catch blocks:
try {
// Your code that might throw
riskyOperation()
} catch (e: Exception) {
// Capture with optional message and context
SecureInspector.captureError(
throwable = e,
message = "Failed to process payment",
context = mapOf(
"orderId" to orderId,
"amount" to amount.toString()
)
)
}
7 Custom Events
Track custom events with properties:
SecureInspector.captureEvent(
name = "purchase_completed",
properties = mapOf(
"product_id" to "SKU123",
"price" to "99.99",
"currency" to "EUR"
)
)
8 Mobile Vitals
Mobile Vitals are captured automatically (enabled by default):
Startup Time
Cold start, warm start, and hot start times
Frame Rate
Dropped frames, slow frames, frozen frames
Memory
Current usage, peak usage, low memory warnings
ANR Detection
Main thread blocked for 5+ seconds
Disable if needed:
SecureInspectorConfig.Builder(...)
.setCaptureVitals(false)
.setDetectAnr(false)
.build()
9 WebView Support
Capture WebView navigation and errors (opt-in feature):
// 1. Enable in config
SecureInspectorConfig.Builder(...)
.setCaptureWebView(true)
.build()
// 2. Wrap your WebView
val webView = findViewById<WebView>(R.id.webView)
SecureInspector.wrapWebView(webView)
// Or with existing WebViewClient
SecureInspector.wrapWebView(webView, myWebViewClient)
10 Timber Integration
Automatically capture errors logged via Timber:
// After SDK initialization
SecureInspector.plantTimberTree()
// Now all Timber.e() calls with exceptions are captured
Timber.e(exception, "Something went wrong")
11 Configuration Options
val config = SecureInspectorConfig.Builder(
serverUrl = "https://your-server.com",
apiKey = "your-api-key",
encryptionKey = "your-encryption-key"
)
// Session polling interval
.setSessionCheckInterval(30, TimeUnit.SECONDS)
// Max request/response body size to capture
.setMaxBodySize(1024 * 1024) // 1MB
// Exclude URLs from capture
.addExcludeUrlPattern(".*analytics.*")
.addExcludeUrlPattern(".*tracking.*")
// Add custom sensitive headers to mask
.addSensitiveHeader("X-Custom-Auth")
// Add custom sensitive fields to mask
.addSensitiveField("ssn")
.addSensitiveField("taxId")
// Feature toggles
.setCaptureHttp(true)
.setCaptureCrashes(true)
.setCaptureVitals(true)
.setDetectAnr(true)
.setCaptureUserInteractions(true)
// Debug mode (logs to Logcat)
.setDebugMode(BuildConfig.DEBUG)
// Error callback
.setErrorCallback { error ->
Log.e("SecureInspector", "SDK Error", error)
}
.build()
12 ProGuard Rules
Add these rules to your proguard-rules.pro:
# SecureInspector SDK
-keep class com.secureinspector.** { *; }
-keepnames class com.secureinspector.** { *; }
# Keep model classes for JSON serialization
-keepclassmembers class com.secureinspector.capture.** { *; }
-keepclassmembers class com.secureinspector.models.** { *; }
API Reference
SecureInspector.init(application, config)
Initialize the SDK. Call in Application.onCreate().
SecureInspector.getInterceptor()
Get OkHttp interceptor for HTTP capture.
SecureInspector.setUserId(userId)
Set current user ID (after login).
SecureInspector.clearUserId()
Clear user ID (on logout).
SecureInspector.captureError(throwable, message?, context?)
Manually capture a handled exception.
SecureInspector.captureEvent(name, properties?)
Capture a custom event with optional properties.
SecureInspector.isSessionActive()
Check if a debug session is currently active.
SecureInspector.flushCaptures()
Force send all pending captures.
SecureInspector.clearLocalData()
Delete all locally stored captures.
Need Help?
Having trouble integrating? Our team is here to help you get started.
Contact Support