linkUnder the Hood - Android App Debug View Library

Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in. There is a lot of "default" debug data that can be easily embedded (e.g. current runtime-permission status, app version and device info). There are 2 basic themes (dark and light) which can be customized to your needs. The lib is divided into 2 modules: hood-core containing the basic view that can be embedded anywhere and hood-extended which comes with a ready-to-use activity with a lot of convenience features. The lib has also a null-safe no-op flavor indented to be used in release builds, disabling all debug features without error-prone if-debug chains.

Download Build Status Maintainability Javadocs API 14+ Method Cound play store banner

To check it out, download the demo app from the Playstore . Lib and demo app require SDK 14+.


screenshot gallery

linkQuick Start

Add the following to your dependencies (add jcenter to your repositories if you haven't)

1compile 'at.favre.lib.hood:hood-extended:x.y.z'

Create an activity and extend PopHoodActivity. Define it in your AndroidManifest:


2 android:name="com.example.your.MyDebugActivity"

3 android:theme="@style/HoodThemeDark">


Implement the config and page setter in the Activity:

1public class MyDebugActivity extends PopHoodActivity {

2 @Override

3 public Pages getPageData(@NonNull Pages pages) {

4 Page firstPage = pages.addNewPage();

5 firstPage.add(Hood.get().createHeaderEntry("System Features"));

6 firstPage.add(Hood.get().createPropertyEntry("The Key", "The value"));

7 firstPage.add(DefaultProperties.createSectionBasicDeviceInfo());

8 firstPage.add(Hood.get().createActionEntry(DefaultButtonDefinitions.getGlobalSettingsAction()));

9 firstPage.add(new PackageInfoAssembler(PackageInfoAssembler.Type.PERMISSIONS, PackageInfoAssembler.USES_FEATURE).createSection(this, true));


11 return pages;

12 }


14 @Override

15 public Config getConfig() {

16 return Config.newBuilder().setLogTag("MyDebugActivity").build();

17 }


See demo app for extended samples.

linkUsing only the View

Add the view to your layout:


2 android:id="@+id/debug_view"

3 android:layout_width="match_parent"

4 android:layout_height="match_parent"

5 android:theme="@style/CustomHoodViewOverlayDark" />

Create the following style:

1<style name="CustomHoodViewOverlayDark" parent="ThemeOverlay.AppCompat.Dark">

2 <item name="android:background">?android:windowBackground</item>

3 <item name="hoodZebraColor">@color/hoodlib_zebra_color_dark</item>

4 <item name="hoodTextSizeNormal">@dimen/hoodlib_standard_text_size</item>

5 <item name="hoodTextSizeHeader">@dimen/hoodlib_header_text_size</item>

6 <item name="hoodViewpagerTabTextColor">@android:color/primary_text_dark</item>

7 <item name="hoodViewpagerTabBackgroundColor">?attr/colorPrimary</item>


Set up in your controller (Activity or Fragment):

1HoodDebugPageView debugView = (HoodDebugPageView) findViewById(;


3Pages pages = Hood.get().createPages(Config.newBuilder().setShowHighlightContent(false).build());

4Page firstPage = pages.addNewPage("Debug Info");



7Page secondPage = pages.addNewPage("Debug Features");


9secondPage.add(new PackageInfoAssembler(PackageInfoAssembler.Type.APK_INSTALL_INFO, PackageInfoAssembler.Type.PERMISSIONS).createSection(this, true));



linkShowcase Demo App

animation of ui

linkThe HoodAPI

The main interface of the App is the HoodAPI or HoodAPI.Extension accessed through the Hood singleton. It is required to use these interfaces to take advantage of using the no-op flavor.

The interface is used with the Hood singleton:



For default properties/actions/etc checkout the classes in


as well as PackageInfoAssembler.

linkThe DebugView

Responsible for rendering and the main interface for the Activity/Fragment to the debug pages is the HoodDebugPageView. Define it in your view


2 ...


For themes see section below.

To initialize the view it needs a Pages object:


If there is more than 1 page the pages are rendered in a ViewPager with simple tabs on top, otherwise it will just show as a single page.



the entries can be refreshed (see DynamicValue). To block the view and show a progress bar you can use:


Note that your Activity should implement IHoodDebugController to enable all features. This is necessary so external ui elements (like DialogFragments) can communicate with the debug view.


The config object must be created with the provided builder:

1Config.newBuilder() (...) .build()

Following configs can be changed:

linkTemplate Concept

The template has the following main components

adiagram showing how the template works

Additionally there is an element that groups a bunch of PageEntry entries with additional convenience logic, like displaying an optional error message.

Creating a simple page is easy:

1 Pages pages = Hood.get().createPages(Config.newBuilder().build());

2 Page firstPage = pages.addNewPage("Title Page 1");

3 firstPage.add(...);

4 ...


6 Page secondPage = pages.addNewPage("Title Page 2");

7 secondPage.add(...);

8 ...

PageEntry elements, that can be added to a Page can be created like this:

1 page.add(Hood.get().createHeaderEntry(...))

2 page.add(Hood.get().createPropertyEntry(...))

3 page.add(Hood.get().createActionEntry(...))

4 page.add(Hood.get().createSwitchEntry(...))

5 page.add(Hood.get().createSpinnerEntry(...))

linkBuilt-In PageEntry Elements

linkProperty Entry

example in the ui

Create with:

1 Hood.get().createPropertyEntry("The Key", "The value")

Will render a row with a the key string on the one side and the value on the other. Supports dynamic values (ie. every refresh will be reevaluated), multi-line layout for longer values and custom on-tap-actions and background evaluating values.

For example a property element that will show the uptime (which will get update if the DebugView will be refreshed) and a toast message when the user clicks on it:

1 Hood.get().createPropertyEntry("uptime", new DynamicValue<String>() {

2 @Override

3 public String getValue() {

4 return HoodUtil.millisToDaysHoursMinString(SystemClock.elapsedRealtime());

5 }

6 }, Hood.ext().createOnClickActionToast(),false);

If you want the lib to evaluate the value in background instead of the main thread use DynamicValue.Async instead of DynamicValue

Default actions are: Toast, Dialog, Start-Intent and ask runtime permission.

For a lot of default data, e.g. device info, set permissions and build data, see DefaultProperties.* and PackageInfoAssembler


example in the ui

Will be rendered as a simple button starting a custom action on click. Supports single and double column actions (ie. having two buttons in the same row)

Here is a simple example:

1 Hood.get().createActionEntry(new ButtonDefinition("Click me", new OnClickAction() {

2 @Override

3 public void onClick(View v, Map.Entry<CharSequence, String> value) {

4 Toast.makeText(v.getContext(), "On button clicked", Toast.LENGTH_SHORT).show();

5 }

6 }));

For a lot of default actions, e.g. android settings, app-info or uninstall and kill process, see DefaultButtonDefinitions class.

linkConfigBoolEntry & ConfigSpinnerEntry

For interactive debug features the standard implementations for switches and spinner can be used. The logic for the switch can be anything that implements the ChangeableValue interface. Spinner can also be customized to your demands.

For a simple switch that changes a boolean in the shared preference see this example:

1 Hood.get().createSwitchEntry(

2 DefaultConfigActions.getBoolSharedPreferencesConfigAction(

3 getPreferences(MODE_PRIVATE),

4 "SHARED_PREF_KEY", "Enable debug feat#1", false));

example in the ui

This code will create a simple backend switcher:

1 Hood.get().createSpinnerEntry(

2 DefaultConfigActions.getDefaultSharedPrefBackedSpinnerAction(

3 "Backend", getPreferences(MODE_PRIVATE),

4 "BACKEND_ID", null, getBackendElements())));


6 private List<SpinnerElement> getBackendElements() {

7 //return your backends

8 }

example in the ui

There is a standard implementation for ConfigBoolEntry in DefaultConfigActions backed by shared preferences.

linkHeader and Message

Group your entries with a header

1 Hood.get().createHeaderEntry("App Version")

example in the ui

To display a simple message use the following:

1 Hood.get().createSimpleMessageEntry("This is a simple message shown in ui")

linkCustom PageEntries

A PageEntry must implement the interface with the same name. It holds a distinct value, can be refreshed and returns a loggable string. The most important part, though, is the ViewTemplate that defines how this entry is rendered. The constructView and setContent are similar to the onCreateViewHolder and onBindViewHolder in a RecyclerView. It is important that ViewTemplate must return a distinct type as int (values over 65536 are reserved by the lib)

linkLibrary Modules and Flavours

The library comes in 2 modules:

linkModule hood-core

Contains only the base code without the default implementation of the debug activity. The advantage is that there is only minimal dependencies on support* libraries and therefore very lightweight, not adding too much methods or res to your app.

The core module comes in 2 flavours (or classifier):


The standard version of the lib with all features. You could use this version in only in your debug builds with:

1 compile("at.favre.lib.hood:hood-core:x.x.x")


The no-op version of the lib internally using null-safe no-op versions of the main template system. All creator methods of HoodAPI (Hood.get()) and HoodAPI.Extension (Hood.ext()) support the no-op switch and return dummy implementations. If you use implementation from** directly this will have no effect.

Here is a piratical example to use default flavor in debug and noop in release:

1 debugCompile('at.favre.lib.hood:hood-core:x.x.x')

2 releaseCompile(group: 'at.favre.lib.hood', name: 'hood-core', version: 'x.x.x', classifier: 'noop', ext: 'aar', transitive: true)

The PopHoodActivity will also respect the no-op switch and just finish. The no-op state can be checked with Hood.isLibEnabled() from any caller.

Here is a example of a noop view being rendered

example image

linkModule hood-extended

Extends the hood-core with a default implementation of a debug activity using appcompat-v7 support library.

If you want to use the noop version in release use something like this:

1 debugCompile('at.favre.lib.hood:hood-extended:x.x.x')

2 releaseCompile('at.favre.lib.hood:hood-extended:x.x.x') {

3 exclude group: 'at.favre.lib.hood', module: 'hood-core'

4 releaseCompile(group: 'at.favre.lib.hood', name: 'hood-core', version: 'x.x.x',

5 classifier: 'noop', ext: 'aar', transitive: true)

6 }


The lib defines some required attributes, so they need to be set in order to be able to render the view. The easiest way is to use the build-in themes (hood-extended) for Activities (which extend from Theme.AppCompat)

and overlays for standalone views:

You can also define your own theme (extending Theme.AppCompat or ThemeOverlay.AppCompat) but you must define the following attributes in it:

Here is an example with useful defaults:

1 <style name="HoodThemeDark" parent="Theme.AppCompat.NoActionBar">

2 ...

3 <item name="hoodToolbarTextColor">@android:color/primary_text_dark</item>

4 <item name="hoodZebraColor">@color/hoodlib_zebra_color_dark</item>

5 <item name="hoodTextSizeNormal">@dimen/hoodlib_standard_text_size</item>

6 <item name="hoodTextSizeHeader">@dimen/hoodlib_header_text_size</item>

7 <item name="hoodViewpagerTabTextColor">@android:color/primary_text_dark</item>

8 <item name="hoodViewpagerTabBackgroundColor">?attr/colorPrimary</item>

9 </style>

linkAdditional Features

linkUsing the Shake Detector to open the Debug View

Use the HoodAPI.Extension interface to register your intent:

1 shakeControl = Hood.ext().registerShakeToOpenDebugActivity(this,

2 PopHoodActivity.createIntent(this, MyDebugActivity.class));

Then start/stop the detector onResume()/onPause()

1 @Override

2 protected void onResume() {

3 super.onResume();

4 shakeControl.start();

5 }


7 @Override

8 protected void onPause() {

9 super.onPause();

10 shakeControl.stop();

11 }

linkUsing the Arbitrary Tap ClickListener

If you want to obfuscate the access point of your debug view with e.g. a triple click on a view that does not look clickable use the following code:

1 myView.setOnTouchListener(Hood.ext().createArbitraryTapListener(3, new View.OnClickListener() {

2 @Override

3 public void onClick(View v) {

4 PopHoodActivity.start(WrappingActivity.this, MyDebugActivity.class);

5 }

6 }));

linkPossible conflicts and things to mind

This lib uses Timber for logging, but will never plant a Tree, so to not interfere with the root app's desired logging behaviour. If you like to see the lib's logging output just plant a DebugTree

1Timber.plant(new Timber.DebugTree());

All res assets are prefixed with hoodlib_ so there should be no conflict when merging the resources.


The lib includes it's own proguard consumer rules and should work out of the box with obfuscated builds.


linkSuggestions on what Properties/Actions to add to your Page

Apart from DefaultProperties the following could be useful:

git-hash, git-branch, CI build no, build time, login-data, internal states

The following debug actions might be useful:

clear (image) caches, manually calling requests, updating ui, changing shared pref states, directly open activities

linkStart your debug activity through adb

Add android:exported="true" to your activity definition and use the following adb call:

1 adb shell am start -n

linkHave certain debug features only in debug builds

Use a static boolean (e.g. BuildConfig.DEBUG) in an if like

1if(BuildConfig.DEBUG) {

2 page.addAction(...)


Although verbose, the advantage is that the compiler will remove the unreachable code in release builds similar to using C macros.


Assemble the lib with the following command

1./gradlew :hood-core:assemble

2./gradlew :hood-extended:assemble

The .aar files can then be found in /hood-*/build/outputs/aar folder

linkLibraries & Credits

linkSimilar Projects:


Copyright 2017 Patrick Favre-Bulle

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Under the Hood - Android App Debug View LibraryFeaturesQuick StartUsing only the ViewShowcase Demo AppThe HoodAPIThe DebugViewConfigTemplate ConceptBuilt-In PageEntry ElementsProperty EntryActionEntryConfigBoolEntry & ConfigSpinnerEntryHeader and MessageCustom PageEntriesLibrary Modules and FlavoursModule hood-corereleasenoopModule hood-extendedThemeAdditional FeaturesUsing the Shake Detector to open the Debug ViewUsing the Arbitrary Tap ClickListenerPossible conflicts and things to mindProguardRecipesSuggestions on what Properties/Actions to add to your PageStart your debug activity through adbHave certain debug features only in debug buildsBuildLibraries & CreditsSimilar Projects:License



Patrick Favre-Bulle 2020