为 Facebook 截图测试设置适用于 android 的 gradle 插件时出现问题



我需要为安卓实现屏幕截图测试。

我已经按照 https://facebook.github.io/screenshot-tests-for-android/#gradle-setup 的步骤操作,并且我的gradle文件中有以下内容

buildscript {
// ...
dependencies {
// ...
classpath 'com.facebook.testing.screenshot:plugin:0.9.0'
}
}
apply plugin: 'com.facebook.testing.screenshot'

但是,我收到一个错误

评估根项目"app-android"时出现问题。 无法应用插件 [id 'com.facebook.testing.screenshot'] 找不到名称为"androidTestImplementation"的配置。

我的build.gradle中有以下内容

androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.multidex:multidex-instrumentation:2.0.0'

我找不到任何证据表明我需要其他任何东西。

我也在 https://github.com/facebook/screenshot-tests-for-android 上看到过

您需要 python-2.7 才能使 gradle 插件正常工作,我们还建议安装 python-pillow 库,这是记录和验证屏幕截图所必需的。

我已经安装了它,看到我有版本 2.7.16 我还安装了建议的枕头(v6.0.0)

您可能需要移动以下行:

apply plugin: "com.facebook.testing.screenshot"

进入模块级别build.gradle. 它必须低于这一行:

apply plugin: "com.android.application"

因为这就是androidTestImplementation的来源。

文档中不清楚

该行:

classpath 'com.facebook.testing.screenshot:plugin:0.14.0'

进入项目的 gradle 文件 (build.gradle .)

还有那行:

apply plugin: 'com.facebook.testing.screenshot'

进入应用的 gradle 文件(build.gradle 应用)

最新更新