Android测试覆盖率报告因Proguard警告而失败

时间:2018-10-15 11:36:12

标签: android unit-testing gradle code-coverage

我正在尝试在Android Studio项目上执行android测试覆盖率报告。并且它产生以下错误,但是应用模块运行了 并成功构建。

Note: there were 13 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 81 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Warning: there were 133 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 17 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
Warning: there were 1 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
Thread(Tasks limiter_2): destruction
> Task :mobile:transformClassesAndResourcesWithProguardForAlphaEssayerAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mobile:transformClassesAndResourcesWithProguardForAlphaEssayerAndroidTest'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 55s

我将以下行添加到build.gradle文件中以设置覆盖率报告:

apply plugin: 'jacoco'

testCoverageEnabled = true在buildTypes部分

还有

android.testOptions {
    unitTests.all {
        jacoco {
            includeNoLocationClasses = true
        }
    }
}

我是摇摇晃晃的菜鸟。但是,proguard与代码覆盖率报告有何关系,是否不应该仅针对发行版本启用它?

0 个答案:

没有答案