androidx.test.InstrumentationRegistry is deprecated

后端 未结 6 887
耶瑟儿~
耶瑟儿~ 2020-12-24 04:49

Switched to AndroidX and received deprecated: import androidx.test.InstrumentationRegistry.

If I made next import: import androidx.te

6条回答
  •  时光取名叫无心
    2020-12-24 05:30

    The following code is deprecated now:

    Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
    

    Instead use:

    Context context = ApplicationProvider.getApplicationContext();
    

提交回复
热议问题