lundi 21 mai 2018

Android Studio : Cannot resolve symbol "Truth" (Truth library)

After coming across this gist : https://gist.github.com/chemouna/00b10369eb1d5b00401b, I noticed it was using the Google Truth library : https://google.github.io/truth/. So I started by following the procedure to add the library in my build.gradle file in Android Studio:

buildscript {
  repositories.mavenLocal()
}

dependencies {
  testImplementation "com.google.truth:truth:0.40"
}

But when I wanted to add the static imports for Truth’s entry points for my assertions java class:

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

I got the error that the symbol Truth cannot be resolved. I tried to rebuild my project and implement the solutions stated here: AndroidTestCompile dependencies not recognized in the imports, mainly running the following gradle tasks:

  • ./gradlew app:dependencies
  • assembleAndroidTest

but the problem persists.

Any help on that?

Aucun commentaire:

Enregistrer un commentaire