Skip to content

saravr/android-debug-library

 
 

Repository files navigation

Introduction

This library provides an on-device solution for obtaining and displaying debug information related to the app, with options to export data as needed. It is enabled exclusively for DEBUG builds, while a no-op version is available for RELEASE variants. Designed to assist both developers and QA teams, it streamlines issue reporting and diagnostics during development and testing. A key advantage of this library is that all debugging insights are accessible directly on the device, eliminating the need for external tools.

Caution

The information collected, stored and shared MAY contain sensitive information and/or impact the privacy policy of the app. This library should STRICTLY be used only for debugging purposes, and NEVER in production.

Features

The debug information collected and reported include:

  • Network traffic
  • Logcat output
  • Summary of Room Database storage
  • Shared preferences
  • Status of network, power, and audio systems

The recorded information is persisted on the device, ensuring availability even after a crash. Note: To prevent excessive growth, older entries will be periodically purged.

Network traffic

The library uses an ASM based gradle plugin to intercept OkHTTP traffic (no need to add Interceptors manually).

Traffic log

Details

Logcat

Logcat output

Room Database

Room DB

Device Monitor

Network Monitor

Power and Audio

Share the collected information

Share debug information

How to use

Gradle changes

Add to repositories

    repositories {
        maven { url = uri("https://jitpack.io") }
    }

Add to root project gradle file

plugins {
    id("com.sandymist.mobile.plugin.interceptor") version "0.1.3" apply false
}

Add to app gradle file as follows

    plugins {
        id("com.sandymist.mobile.plugin.interceptor")
    }

    interceptor {
        targetClassName = "com.sandymist.mobile.plugins.network.NetworkPlugin"
    }

    dependencies {
        debugImplementation("com.github.sandymist.android-debug-library:debuglib-debug:<version>")
        releaseImplementation("com.github.sandymist.android-debug-library:debuglib-no-op:<version>")
    }

Code changes

Integrate Debug menu into the app's UI.

Step 1: Add this line in Application onCreate() (in debug source set)

    DebugLib.init(this)

Step 2: Add UI hook

Option 1: Call the composable function directly.

    import com.sandymist.android.debuglib.ui.DebugScreen

    DebugScreen(modifier: Modifier)

Option 2: Launch the DebugActivity (non-Jetpack-Compose apps)

    import com.sandymist.android.debuglib.ui.DebugActivity

    val intent = Intent(context, DebugActivity::class.java)
    context.startActivity(intent)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%