切换到AndroidX
并收到弃用的:import androidx.test.InstrumentationRegistry
。
如果我做了下一个导入:import androidx.test.platform.app.InstrumentationRegistry
,我就不能使用getContext()
了。
例如:val context = InstrumentationRegistry.getContext()
。
在build.gradle
中
androidTestImplementation 'androidx.test.ext:junit:1.0.0-beta02'
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
发布于 2019-03-12 23:43:53
对于Kotlin用法,为了获取上下文:
InstrumentationRegistry.getInstrumentation().targetContext
https://stackoverflow.com/questions/52924431
复制相似问题