将proguard与浓缩咖啡/androidTest一起使用
我正在尝试将proguard配置为与我的浓缩咖啡UI测试味道一起使用。问题是Proguard倾向于忽略我的调试Proguard配置 以下是配置的外观:将proguard与浓缩咖啡/androidTest一起使用,android,proguard,android-espresso,Android,Proguard,Android Espresso,我正在尝试将proguard配置为与我的浓缩咖啡UI测试味道一起使用。问题是Proguard倾向于忽略我的调试Proguard配置 以下是配置的外观: buildTypes { debug { minifyEnabled true proguardFiles 'proguard-debug.pro' testProguardFile 'proguard-debug.pro' signingConfig signingConf
buildTypes {
debug {
minifyEnabled true
proguardFiles 'proguard-debug.pro'
testProguardFile 'proguard-debug.pro'
signingConfig signingConfigs.release
}
}
我添加了testProguardFile
,但它似乎对androidTest
不起作用。我正在运行mockDebug
flavor variant。当我刚刚运行应用程序时,它工作正常,但当我尝试运行位于adnroidTest
中的测试时,由于proguard警告,它将不会运行,例如proguard文件根本没有被处理,文件非常简单:
proguard debug.pro
-dontobfuscate
-dontoptimize
-dontwarn
在有人建议我关闭调试版本的proguard之前:我需要启用它,因为multidex。您还需要添加默认的proguard规则:
proguardFiles getDefaultProguardFile('proguard-android.txt')
此行可以删除,因为它是重复的:
testProguardFile 'proguard-debug.pro'
如果您希望测试构建尽可能接近真实交易,请尝试以下方法:
# build.gradle
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFile 'proguard-test.pro'
}
及
另一方面,若您仅仅因为multidex而需要它,若您使用的是minSdkVersion<21,则ProGuard将绑定到multidex标志并自动运行
# proguard-test.pro:
-include proguard-rules.pro
-keepattributes SourceFile,LineNumberTable