Hi,
Scenario:
From time to time the app gets broken when using proguard. This is either during the building process which is an easier case or during the app start on a device usually with some missing classes. To address this I want to enable proguard for the debug build and run simple 'sanity' integration tests. (I understand it will make actual debugging harder but I would like to have at least one build variant with proguard enabled i can test automatically).
Problem:
If i enable proguard like this:
proguardFile 'proguard.cfg'
The build will be fine but it will also try to run proguard on the test apk. It forces me to introduce a test app specific proguard configuration. I want to use the same configuration i use for the release apk.
I can disable proguard task:
gradle.projectsEvaluated {
proguardDebugTest.enabled = false
This will make the build fail because it wont run :preDexDebugTest and the :dexDebugTest task will have no input:
Execution failed for task ':dexDebugTest'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Dev\Android SDK\build-tools\19.0.1\dx.bat --dex --output D:\Workspace\keepsafe\KeepSafe\mobile\android\build\dex\test\debug
I've searched SO and this group but can't find any answer to my problem. Does anybody have a configuration like this running successfully?
If it can't be done like this:
- Can I make integration tests take a release apk?
- The android plugin registers tasks depending on the configuration. If i turn proguard on :preDexDebugTest wont even get registered. Wouldn't it make more sense to register them anyway and build the dependsOn chain depending on configuration?
There is one thing I've noticed while going through the sources. BasePlugin.groovy:1414 has a flag like this:
boolean runProguard = variantConfig.buildType.runProguard &&
(variantConfig.type != TEST ||
(variantConfig.type == TEST &&
variantConfig.testedConfig.type != VariantConfiguration.Type.LIBRARY))
Why it makes sense to run proguard if the test apk is not a library but it doesn't make sense for a library. Is there any reason to run proguard for the test apk at all?
Sorry if this something crazy I'm trying to do, I'm new to Android. I'd be grateful for any tips how I can solve this.
Thanks,
Tomek