I know that I can use debugCompile
to only pull in a dependency
for the debug build
. Is there a good, streamlined way to do the code initialization
that is required as well? Without the dependencies the other variants will fail to compile.
You can change the build variant to whichever one you want to build and run—just go to Build > Select Build Variant and select one from the drop-down menu. To start customizing each build variant with its own features and resources, however, you'll need to know how to create and manage source sets.
To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar. For projects without native/C++ code, the Build Variants panel has two columns: Module and Active Build Variant.
Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle. There are two build types defined by default, debug and release , and you can customize them and create additional build types.
Build Type refers to build and packaging settings like signing configuration for a project. For example, debug and release build types. The debug will use android debug certificate for packaging the APK file. While, release build type will use user-defined release certificate for signing and packaging the APK.
Check the @Tanis answer.
Also you can use something like this:
Add the library only on debug version.
dependencies { debugCompile 'com.facebook.stetho:stetho:1.1.1 }
In your Application you can do :
public class ExampleApplication extends Application { @Override public void onCreate() { super.onCreate(); StethoUtils.install(this); } }
Then you can create different StethoUtils
class in the debug/release version.
In src/debug/java/
public class StethoUtils{ public static void install(Application application){ Stetho.initialize( Stetho.newInitializerBuilder(application) .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)) .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(application)) .build()); } }
In src/release/java/
public class StethoUtils{ public static void install(Application application){ // do nothing } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With