AndroidJUnit4.class is deprecated: How to use androidx.test.ext.junit.runners.AndroidJUnit4?

前端 未结 8 1664
傲寒
傲寒 2020-12-04 08:04

For my instrumentation tests I was using

@RunWith(AndroidJUnit4.class)

from

import androidx.test.runner.AndroidJUnit4;
         


        
8条回答
  •  感情败类
    2020-12-04 08:45

    Solution

    1. Add this line in to build.gradle: androidTestImplementation 'androidx.test.ext:junit:1.1.1'

    2. Change AndroidJUnit4 to AndroidJUnit4ClassRunner in the test class

    Warning

    I got the same error, but the following solution failed for me:

    File -> Invalidate Caches..., and select Invalidate and Restart

提交回复
热议问题