0

After creating class for unit tests like in official documentation I imported com.google.common.truth.Truth.assertThat and org.junit.Test libraries, but android studio can't pick it up and shows errors "Cannot resolve symbol "Truth"" and "Cannot resolve symbol "Test"".

After searching the ways to solve this problem I came across a question on StackOverflow that asked similar thing. I did all the things that were recommended over there but I still can't import those classes.

My project build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

My project module build.gradle

dependencies {
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'com.google.truth:truth:1.1.3'
}

My test class

import com.google.common.truth.Truth.assertThat;
import org.junit.Test;
VeceluXa
  • 17
  • 1
  • 7

1 Answers1

1

Android gradle plugin requires java 11 to run.

Please change gradle java plugin to 11 like below screenshot.

enter image description here

Tareq Islam
  • 124
  • 6