We're working on setting up some Activity instrumentation tests to run on a build server. Since this requires the device to be awake, the options that I've found seem to be:
Set the devices to "Stay Awake" and disable the screen lock
Disable the Keyguard programmatically in the test case (as described here)
Option 1 doesn't seem great as it wastes the battery and will eventually cause burn-in on the device displays. Option 2 seems preferable, but I'd rather keep the DISABLE_KEYGUARD permission strictly to debug builds (not release) so that all product flavors are testable, but the permission is never requested for a release build.
I know we can add manifests to merge using sourceSets:
android.sourceSets.development {
manifest.srcFile 'development/AndroidManifest.xml'
}
But I've not yet found an equivalent way to do so only for specific build types -- something like this (which isn't valid):
buildTypes {
debug {
manifest.srcFile 'debug/AndroidManifest.xml'
}
}
Is there an official way to do this? Any other recommendations? Thanks!
You can have sourceSets for build types the same way as for flavors. This should work:
android.sourceSets.debug {
manifest.srcFile 'debug/AndroidManifest.xml'
}
Having said that, the directory structure means that you shouldn't need to manually configure sourceSets unless you're using a non-default layout. In the standard structure you can do this and not configure sourceSets in your build file at all:
module_directory
+--src
+--main
+--AndroidManifest.xml
+--java
+--res
+--flavor1
+--AndroidManifest.xml
+--java
+--res
+--debug
+--AndroidManifest.xml
+--java
+--res
+--release
+--AndroidManifest.xml
+--java
+--res
etc.
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