Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference, in wrong test scope - Android studio 3.5

Since I've updated to Android Studio 3.5, in my unit tests Android Studio shows unresolved reference for all the dependencies. The project compiles and the unit test runs successfully but Android Studio shows everything in red.

I've tried to clean, delete build and .gradle folder, invalidate caches but it doesn't work.

Unresolved reference

like image 366
cherif Avatar asked Aug 29 '19 10:08

cherif


People also ask

How to fix Unresolved reference Android Studio?

If you still see the unresolved reference error after fixing the problem, try to build your Android application with Command + F9 for Mac or Control + F9 for Windows and Linux. The error should disappear after the build is completed.

What is androidTestImplementation?

androidTestImplementation—The dependency is only available in the androidTest source set. Android source sets are : main: Contains your app code. This code is shared amongst all different versions of the app you can build (known as build variants) androidTest: Contains tests known as instrumented tests.


1 Answers

Only workaround to fix this until issue 140375151 is resolved is this:

  1. Put the cursor on one of the affected references
  2. Type alt/options + Enter
  3. Choose Inspection "Unresolved reference, in wrong test scope"
  4. Choose Edit inspection profile setting
  5. Remove the check from the inspection setting to disable it and click OK

The unresolved references should no longer show as unresolved.

like image 101
Bohsen Avatar answered Oct 13 '22 22:10

Bohsen