Skip to content

Android Could Not Resolve Error

Android could not resolve error#

If you are sure there are no spelling errors in your dependency and the project is hosted in the expected repository, check the Gradle wrapper and repository configuration next.

Common messages include:

  • Failed to resolve ...
  • Unable to compile
  • Peer not authenticated

These notes came from Android Studio 1 and 2 era projects, so treat them as historical troubleshooting steps for old codebases. For a modern project, first check the Android Gradle Plugin and Gradle compatibility matrix in the Android documentation.

Checks#

  1. Confirm the dependency coordinates are correct
  2. Confirm the repository is declared in the right place. Older projects usually used allprojects.repositories; newer projects often use dependencyResolutionManagement in settings.gradle
  3. Confirm the Gradle wrapper version is compatible with the Android Gradle Plugin version
  4. Check whether the dependency is served from Maven Central, Google Maven, JitPack or a private repository

Wrapper refresh#

If the wrapper is too old for the project, change distributionUrl in gradle-wrapper.properties to a compatible Gradle distribution.

Then run a Gradle wrapper task from the command line:

cd ~/AndroidStudioProject/myproject/myapp
./gradlew tasks

If this works from the command line but not Android Studio, invalidate caches and re-import the project.

Sources#