On older devices (I tested v10 and 15), I cannot install any debug app build without using ProGuard because of this problem: Can't upload Android app to device (stale dexed jars)
Using ProGuard temporarily for the debug build with options -dontobfuscate and implicit shrinking reduces the number of methods and so allows running the app on those devices. Currently, I have found no other solution.
The same problem comes up when trying to run instrumented tests of my library on old devices. To allow code shrinking separately for this library, I changed its build.gradle:
apply plugin: 'com.android.library'
...
android {
..
buildTypes {
debug {
minifyEnabled true
shrinkResources false
testProguardFile 'proguard-rules.pro'
// or testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
...
}
}
(Hint: The library debug build is usually irrelevant for all builds besides instrumented tests because Android always uses release builds if the library is built as a dependency.)
Executing an instrumented Test of my library on an emulator (v15), I get the following kinds of errors:
Error:(19, 33) error: package my.proj....Config does not exist
Error:(18, 31) error: cannot find symbol variable ClassName
It does not find any symbols of the default source set of the library itself. This only happens with minifyEnabled true
. How can this happen?