android-studio - 更改 Android Studio 运行配置中的检测类

标签 android-studio

我的 Android 项目有一些复杂的测试设置,它需要不同的测试运行器。我已经设置了我的 Gradle 文件,以便它根据项目属性切换测试运行器。这样我就可以在通过 Gradle 脚本运行测试时控制测试运行器。

但是,我很乐意对 Android Studio 运行配置执行相同的操作。但是Instrumentation Class 字段似乎是灰色的,AS 不让我更改它。 See here .

最佳答案

我遇到了同样的问题,通过在 build.gradle 中设置 testInstrumentationRunner 解决了这个问题,例如

android {
   defaultConfig {
       ...
       testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

当然,它是否有效取决于您的 Gradle 设置 - 您写道您正在做一些复杂的事情,但这可能是一个开始的地方。

关于android-studio - 更改 Android Studio 运行配置中的检测类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65401620/

相关文章:

gradle - Android Studio构建错误

java - 如何修复右按钮边框未在应用程序中显示?

java - 如何修复在空对象引用上调用虚拟方法 'android.view.View androidx.fragment.app.FragmentActivity.findViewById(int)' 的尝试?

android - 更新 Android Studio 时出错

android - Facebook SDK 出现“ANDROID_BUILD_SDK_VERSION”错误

android - 在 Android Studio 中添加 android.jar 作为模块的依赖项

android-studio - 在源代码中查看资源变量内容的快捷方式?

android-studio - Android Studio 3.0 预览缺少 'use the same device for future launch' 复选框

android - 如何通过点击通知调用电话

java - 添加 Google Play 服务和 Proguard 时出现警告?