Based on Android Debug Drawer with ideas from Jake Wharton's u2020.
- GradleModule to make your QA happy.
- EnablerModule & SelectorModule to replace build flavors in single apk.
//Extension: Build Info Module
implementation 'com.noveogroup:debugdrawer-buildinfo:0.0.5'
//Extension: Build Config Module (implicit dependency on debugdrawer-buildconfig-base)
debugImplementation 'com.noveogroup:debugdrawer-buildconfig:0.0.5'
releaseImplementation 'com.noveogroup:debugdrawer-buildconfig-no-op:0.0.5'
//Debug Drawer https://github.com/palaima/DebugDrawer
debugImplementation 'io.palaima.debugdrawer:debugdrawer:0.7.0'
releaseImplementation 'io.palaima.debugdrawer:debugdrawer-no-op:0.7.0'
debugImplementation 'io.palaima.debugdrawer:debugdrawer-view:0.7.0'
releaseImplementation 'io.palaima.debugdrawer:debugdrawer-view-no-op:0.7.0'
BuildInfoModule |
---|
Extracts build source information. Great for CI Integration |
- copy drawer.gradle to your app module
- add these lines to your app/build.gradle:
defaultConfig {
...
buildConfigField 'String', noveoDrawer.who, noveoDrawer.builderInfo()
buildConfigField 'String', noveoDrawer.date, noveoDrawer.buildDate()
}
- add
new GradleModule(BuildConfig.class)
to your DebugDrawer
or extract info manually.
- add info manually
new GradleModule(source, date, flavor, buildType)
SelectorModule |
EnablerModule |
---|---|
Select variant from Spinner | Enable/Disable properties |
The main feature of these modules is that selected properties will be loaded during application.onCreate()
:
- You can switch between production / staging environments with single APK installed.
- It makes easy for you to implement Jake Wharton's u2020 behavior for Stetho & LeakCanary.
- See more in sample app
Create DebugBuildConfiguration
and keep Application scoped reference on it.
DebugBuildConfiguration configuration = DebugBuildConfiguration.init(application);
configuration.enableDebug(); //to enable Slf4j logging
Enabler stetho = Enabler.builder(ENABLER_STETHO, enabled -> {
if (enabled) {
Stetho.initializeWithDefaults(application));
}
})
.initialValue(true)
.releaseValue(false)
.build();
Enabler leak = Enabler.builder(ENABLER_LEAK, enabled -> {
if (enabled) {
LeakCanary.install(application);
}
})
//initial value by default still "false"
.releaseValue(true)
.build();
EnablerModule.init(configuration, stetho, leak, ...);
Selector endpoint = Selector.builder(SELECTOR_ENDPOINT)
.addValues(
"http://staging.noveogroup.com",
"http://production.noveogroup.com"
)
.addValue("http://mock.noveogroup.com")
.initialValue("http://staging.noveogroup.com")
.releaseValue("http://production.noveogroup.com")
.build();
SelectorModule.init(configuration, endpoint, ...);
DebugBuildConfiguration configuration;
String endpoint = configuration.getSelectorProvider().read(SELECTOR_ENDPOINT);
Boolean enabled = configuration.getEnablerProvider().read(ENABLER_STETHO);
Check more examples at sample
Use buildconfig-no-op
version for your release builds.
- Enabler will use only releaseValue (
false
by default) - Selector will use only releaseValue (first from array by default)
- No extra dependencies / methods that explodes your apk release variant
Create separate debugdrawer
module to keep your debug dependencies separate & clean.
//app/build.gradle
dependencies {
...
debugImplementation project(':debugdrawer')
releaseImplementation project(':debugdrawer')
}
And configure your debug dependencies in that module.
//debugdrawer/build.gradle
dependencies {
// Noveo Drawer Modules
api "com.noveogroup:debugdrawer-buildinfo:0.0.1"
debugApi "com.noveogroup:debugdrawer-buildconfig:0.0.1"
releaseApi "com.noveogroup:debugdrawer-buildconfig-no-op:0.0.1"
/* Palamia Debug Drawer */
debugApi "io.palaima.debugdrawer:debugdrawer:0.7.0"
releaseApi "io.palaima.debugdrawer:debugdrawer-no-op:0.7.0"
debugApi "io.palaima.debugdrawer:debugdrawer-view:0.7.0"
releaseApi "io.palaima.debugdrawer:debugdrawer-view-no-op:0.7.0"
/* Other Modules */
api "io.palaima.debugdrawer:debugdrawer-commons:0.7.0"
/* Inspection Tools */
api "com.facebook.stetho:stetho:1.5.0"
debugApi "com.squareup.leakcanary:leakcanary-android:1.5.1"
releaseApi "com.squareup.leakcanary:leakcanary-android-no-op:1.5.1"
}
Please, check the example in sample and sample-drawer modules.
Use api
instead of implementation
to provide dependencies to your app module without duplication.
Copyright (c) 2017 Noveo Group
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.