Cannot resolve symbol AndroidJUnit4

前端 未结 8 1351
太阳男子
太阳男子 2021-01-18 02:24

I\'m trying to add loginfacebook for my app. But when I added a repository that is need in doing this. It caused an error. The AndroidJUnit4 cannot resolve now.

相关标签:
8条回答
  • 2021-01-18 03:04

    If this issue is coming after migrating to AndroidX. Do this:-

    1. Correct imports

    import androidx.test.runner.AndroidJUnit4
    

    instead of

    import android.support.test.runner.AndroidJUnit4
    

    2. Correct method

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

    instead of

    Context appContext = InstrumentationRegistry.getTargetContext()
    
    0 讨论(0)
  • 2021-01-18 03:05

    Try

    androidTestImplementation 'com.android.support:support-annotations:23.1.0'
    androidTestImplementation 'com.android.support.test:runner:0.4.1'
    androidTestImplementation 'com.android.support.test:rules:0.4.1'
    

    Add following above dependencies section

    configurations.all {
       resolutionStrategy.force 'com.android.support:support-annotations:23.1.0'
    }
    
    0 讨论(0)
提交回复
热议问题