【问题标题】:How can I exclude my test classes from my production build using proguard?如何使用 proguard 从我的生产构建中排除我的测试类?
【发布时间】:2018-03-19 19:28:04
【问题描述】:

这是我当前的 proguard 文件。我的单元测试和 UI 测试分别在文件夹 androidTest 和 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 *

【问题讨论】:

    标签: java android gradle build proguard


    【解决方案1】:

    简短的回答是,您不需要。 androidTesttest 源集不包含在您构建时获得的 APK 中,因此您无需担心使用 ProGuard 将它们剥离。

    您可以通过构建 APK 并使用 Android Studio 的 APK Analyzer 来检查自己(只需双击 build/outputs/apk 下生成的 APK)。寻找您的测试课程。你不应该看到它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-06
      • 2011-02-22
      • 2013-01-20
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-05
      相关资源
      最近更新 更多