android - 在 Android Studio 项目上找不到参数的方法 test()

标签 android build.gradle android-studio-3.0 android-junit

在我的 Android 应用程序中,我想在包中排除一些测试用例,以便我在 build.gradle 文件中使用 test 任务。例如:

apply plugin: 'com.android.library'

test{
     exclude '**/calltest/Summary.class'
}

如果同步项目我得到以下异常:

* What went wrong:
A problem occurred evaluating project ':SdkModule'.
> Could not find method test() for arguments [build_4g3vf7b615x3x1p7i9ty0pt1l$_run_closure1@73d026ca] on project ':SdkModule' of type org.gradle.api.Project.

如果我添加 apply plugin : 'java'

CONFIGURE FAILED in 1s
The 'java' plugin has been applied, but it is not compatible with the Android plugins.

请帮我解决这个问题。

最佳答案

尝试为我的 Jenkins 构建生成 XML 测试报告时遇到类似问题。 测试相关设置应该在 testOptions 中。我的文件:

android {
  testOptions {
    unitTests.includeAndroidResources = true
    unitTests.all {
        reports {
            junitXml.enabled = true
            html.enabled = false
        }
    }
}

关于android - 在 Android Studio 项目上找不到参数的方法 test(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54088722/

相关文章:

android - 如何定义适用于 720p 和 1080p 屏幕的布局?

android - 控制音乐播放器服务 fragment 中的播放暂停按钮

android - 是否可以针对不同的产品口味使用不同的 build.gradle?

Android Gradle 库构建 : Include & exclude files from the jar inside the generated aar

gradle - 如何只包含来自main/java的特定文件作为jar的一部分,以使用gradle发布?

java - 在 Ubuntu 上打开项目时 Android Studio 卡住

android - 在 android studio 中成功构建应用程序后如何解决此问题

android - 动态设置ImageView的来源android

android - Android Studio 3.0 : error occur while compiling app

java - Imgproc.getRectSubPix OpenCV 函数在 Java 中给出错误