java如何使用proguard将测试类从生产构建中排除?
这是我当前的proguard文件。我的单元测试和UI测试分别位于安卓Test和Test文件夹中
-target 1.7 #Target version
-dontusemixedcaseclassnames #Specifies not to generate mixed-case class names while obfuscating
-dontskipnonpubliclibraryclasses #Specifies not to ignore non-public library classes
-dontpreverify #Specifies not to preverify the processed class files. when eventually targeting Android, it is not necessary, so you can then switch it off to reduce the processing time a bit.
-verbose #Specifies to write out some more information during processing
-optimizations !code/simplification/arithmetic,!code/allocation/variable
-keep class **
-keepclassmembers class *{*;}
-keepattributes *
# 1 楼答案
简而言之,你不需要这么做
androidTest
和test
源代码集不包括在您构建时获得的APK中,因此您不必担心使用ProGuard将它们剥离出来您可以通过构建一个APK来检查自己,并使用Android Studio的APK分析器查看它(只需双击
build/outputs/apk
下生成的APK)。寻找你的测试课程。你不应该看到他们