APK errors

Gradle sync failed

Error text

Gradle sync failed: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.

Cause

Gradle could not download the project's dependencies. The usual culprits are the network, a missing repository, or a stale cache.

Step-by-step fix

  1. Read the first line of the error. It names the library that could not be found.
  2. Check that settings.gradle lists both google() and mavenCentral() repositories.
  3. Rebuild from the command line with --refresh-dependencies so the cache is refreshed.
  4. Behind a company proxy, put the proxy host and port into gradle.properties.
  5. Make sure the version really exists: look the number up on the library's own page.

Example commands

./gradlew --stop
./gradlew assembleDebug --refresh-dependencies --stacktrace
./gradlew :app:dependencies --configuration debugRuntimeClasspath

How to prevent it

Keep every version in one libs.versions.toml file and sync right after changing it.

Author and license: Nibras Code