简体   繁体   English

我应该使用什么 package 来替换最新 AndroidStudio 中的“android.support.test.rule.ActivityTestRule”?

[英]What package should i use to replace "android.support.test.rule.ActivityTestRule" in the newest AndroidStudio?

I've been debugging a program in AndroidStudio.我一直在 AndroidStudio 中调试一个程序。 The program needs the class "ActivityTestRule" but it shows:该程序需要 class "ActivityTestRule" 但它显示:

“Cannot resolve symbol 'ActivityTestRule' ” “无法解析符号‘ActivityTestRule’”

-the code where ActivityTestRule is used- - 使用 ActivityTestRule 的代码 -

I'm using the newest version of AndroidStudio with the newest version of gradle.我正在使用最新版本的 AndroidStudio 和最新版本的 gradle。 It suggests that there's no android support-v7.这表明没有 android support-v7。 So I use "androidx.test" to replace most packages under "android.support.test", but I cannot find the package to replace "android.support.test.rule.ActivityTestRule".所以我使用“androidx.test”来替换“android.support.test”下的大多数包,但是我找不到package来替换“android.support.test.rule.ActivityTestRule”。

What should i do?我应该怎么办? (Better just change the "import" part of code) (最好只更改代码的“导入”部分)

OK, I've solved this myself:好的,我自己解决了这个问题:

Project structure -> Add the dependency "com.android.support.test:rules:1.0.2" to app denpendencies ->Apply->Done.

In code:在代码中:

#import androidx.test.rule.ActivityTestRule;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActivityTestRule 在 android 测试中被弃用 - ActivityTestRule is deprecated on android test androidStudio 中的“包 android.support.v7.app 不存在”错误 - "package android.support.v7.app does not exist" error in androidStudio 我应该使用“常规”库还是支持库? - What should I use, the 'normal' or the support library? Android仪器测试,库的选择。 我应该使用libs:test:testing-support或test:rules或test:runner? - Android instrumentation tests, choice of libraries. Should I use libs:test:testing-support or test:rules or test:runner? Android:我应该使用什么视频格式/编码来支持大多数Android设备 - Android: What video format/encoding should I use to support most of the android devices 如何在 Kotlin 中将 ActivityTestRule 与 @ClassRule 一起使用? - How do I use an ActivityTestRule with @ClassRule in Kotlin? 我应该用什么来进行碰撞测试? - What should i use to do a collision test it? 如何在Android测试中监听Android ActivityTestRule的beforeActivityLaunched方法 - How to listen Android ActivityTestRule's beforeActivityLaunched method in an android test 如何将 Android SingleLaunchActivityTestCase 转换为 ActivityTestRule? (仪器单元测试) - How to convert Android SingleLaunchActivityTestCase to ActivityTestRule? (Instrumentation unit test) 将@Test批注和ActivityTestRule与Robotium一起使用(Espresso-way) - Use @Test annotation and ActivityTestRule with Robotium (Espresso-way)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM