When you run Gradle Sync or build a project in Android Studio,
an error called “Could not find” may be displayed.
This error occurs when Gradle cannot find a specified dependency, such as a library or plugin, in the configured repositories.
The main possible causes include an incorrect library name or version, missing repository settings, the use of an old library, network problems, or issues with the Gradle cache.
This article explains the main causes and solutions for the “Could not find” error in Android Studio Gradle.
- What Is “Could not find”?
- Main Causes
- Check the Error Message
- Check the Library Name
- Check the Version Number
- Check the repositories Settings
- Check Whether an Additional Maven Repository Is Required
- Check Whether the Library’s Repository Has Changed
- Check Whether Distribution of the Library Has Ended
- Check Old Articles and Sample Code
- Check Gradle Offline Mode
- Check the Internet Connection
- Run Gradle Sync
- Retrieve Gradle Dependencies Again
- When Using Version Catalog
- When “Could not find” Appears for a Plugin
- Check How Dependencies Are Written
- Check “Required by” in the Error
- What to Check for Each Error
- Steps to Check If the Problem Is Not Resolved
- Summary
What Is “Could not find”?
“Could not find” is an error indicating that Gradle could not find the specified dependency in the repositories.
For example, an error like the following may be displayed.
Could not find com.example:library:1.0.0.
In this case, Gradle searched for the dependency
com.example:library:1.0.0,
but could not retrieve it from the configured repositories.
“Could not find” may also be displayed together with errors such as
Could not resolve all files for configuration.
Main Causes
The main causes of the “Could not find” error in Gradle include the following.
- The library name is incorrect
- The group ID or artifact ID is incorrect
- A nonexistent version has been specified
- The required repository is not configured
- The repository where the library is published has changed
- Distribution of the library has ended
- Dependencies from old articles or sample code are being used
- Gradle Offline mode is enabled
- There is a problem with the network connection
- There is a problem with the Gradle cache
Point:
By checking the
group ID,
artifact ID, and
version
displayed after “Could not find,” you can identify which dependency could not be retrieved.
Check the Error Message
First, check the entire error message displayed in the Build window or during Gradle Sync.
For example, an error like the following may be displayed.
Could not find com.example:library:1.0.0.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/...
https://repo.maven.apache.org/maven2/...
In this case, you can see that Gradle searched the displayed repositories but could not find the target library.
If
Searched in the following locations
is displayed in the error, you can also determine which repositories Gradle checked.
Check the Library Name
If the library name written in the dependency is incorrect, Gradle cannot find the target file.
For example, suppose you have written the following dependency.
implementation("com.example:library:1.0.0")
If there is a typo in
com.example
or
library,
the
Could not find
error will occur.
Check the library’s official documentation and confirm that the dependency is written correctly.
Check the Version Number
Even if the library name is correct, it cannot be retrieved if a nonexistent version has been specified.
implementation("com.example:library:9.9.9")
If the specified
9.9.9
has not been published, Gradle cannot find the target file.
Check the library’s official documentation or the list of published versions and specify a version that actually exists.
Check the repositories Settings
Even if the library exists, it cannot be retrieved if the repository where the library is published is not configured in Gradle.
In Android projects, Google Maven Repository and Maven Central are commonly used.
repositories {
google()
mavenCentral()
}
In current Gradle projects, repositories may be configured inside
dependencyResolutionManagement
in
settings.gradle
or
settings.gradle.kts.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
Depending on the library you use, you may need to add repositories other than
google()
and
mavenCentral().
Check the library’s official documentation for the required repository.
Check Whether an Additional Maven Repository Is Required
Some libraries are published in their own Maven Repository or another repository rather than Maven Central or Google Maven Repository.
In that case, you need to add the specified repository.
repositories {
google()
mavenCentral()
maven {
url = uri("https://example.com/maven")
}
}
However, rather than adding unnecessary repositories indiscriminately, check and configure the official distribution location of the library you are using.
Check Whether the Library’s Repository Has Changed
For some libraries, the repository where they are published may change from the one used previously.
Old sample code may assume the use of a previous repository, so the library may no longer be retrievable from the current distribution location.
In particular, when opening an old Android project, check the library’s current official documentation.
Check Whether Distribution of the Library Has Ended
For libraries that have not been updated for a long time, distribution itself may have ended.
Even a dependency that could previously be retrieved may produce a
Could not find
error if it is removed from the repository.
In this case, it may be necessary to replace it with a successor library or another library.
Check Old Articles and Sample Code
Old Android Studio articles and sample code on the web may contain dependencies that are no longer available.
Even if they worked correctly when the article was created, they may no longer be retrievable due to changes in library versions or distribution locations.
If you copied sample code as-is, compare the dependency declarations with the current official documentation.
Check Gradle Offline Mode
When Gradle Offline mode is enabled, Gradle does not connect to the internet and uses only the cache stored locally.
If the required library has not yet been downloaded, it cannot be retrieved in Offline mode.
Check the Gradle settings in Android Studio, and if Offline mode is enabled, disable it and then run Gradle Sync.
Check the Internet Connection
If you are not connected to the network, Gradle cannot retrieve libraries from external repositories.
Check your internet connection using a browser or another method, and reconnect if your Wi-Fi or other connection is unstable.
However, if there is a problem with the network connection itself, other errors such as
Could not GET
or
Connection timed out
may also be displayed.
Run Gradle Sync
If Gradle Sync has not completed successfully after changing dependencies, the dependencies may not have been applied correctly.
Run
Sync Project with Gradle Files
or a similar option from Android Studio to resynchronize the Gradle settings.
If the retrieval error is temporary, resynchronizing may resolve the problem.
Retrieve Gradle Dependencies Again
If there is a problem with the Gradle cache, retrieving the dependencies again may resolve the issue.
Run the following from the project’s Terminal.
./gradlew build --refresh-dependencies
On Windows, depending on the environment, run the following.
gradlew.bat build --refresh-dependencies
This rechecks the dependency cache and retries retrieving the required files.
When Using Version Catalog
In projects that use Gradle Version Catalog, library names and versions may be defined in
libs.versions.toml.
[versions]
example = "1.0.0"
[libraries]
example-library = { module = "com.example:library", version.ref = "example" }
In this case, check not only
build.gradle.kts
but also the module name and version in
libs.versions.toml
for errors.
When “Could not find” Appears for a Plugin
The
Could not find
error may be displayed not only when a library cannot be retrieved, but also when a Gradle plugin cannot be retrieved.
In the case of a plugin, check the repository settings for plugins separately from normal dependencies.
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
Also check whether the plugin ID and version are correct.
Check How Dependencies Are Written
The way dependencies are written may differ between Groovy DSL and Kotlin DSL.
In Kotlin DSL, for example, they are written as follows.
dependencies {
implementation("com.example:library:1.0.0")
}
In Groovy DSL, they may be written as follows.
dependencies {
implementation 'com.example:library:1.0.0'
}
Check that the syntax matches the
build.gradle
or
build.gradle.kts
file you are using.
Check “Required by” in the Error
After “Could not find,”
Required by
may be displayed.
Could not find com.example:library:1.0.0.
Required by:
project :app
By checking this section, you can determine which module or dependency requires the target library.
The cause may be a dependency indirectly required by another library rather than a library you added directly.
What to Check for Each Error
The information displayed together with “Could not find” can help narrow down the cause to some extent.
| Displayed Information | Main Points to Check |
|---|---|
| Could not find ~ | Library name, version, repository |
| Searched in the following locations | Repositories searched by Gradle |
| Required by | Module that requires the dependency |
| Could not GET | Network, proxy, repository connection |
| Connection timed out | Network, firewall, proxy |
Steps to Check If the Problem Is Not Resolved
If you do not know the cause, checking the following in order makes it easier to narrow down the problem.
- Check the library name displayed after “Could not find”
- Check whether the group ID and artifact ID are correct
- Check whether the specified version exists
- Check repository settings such as
google()andmavenCentral() - Check whether an additional Maven Repository is required
- Check whether the library’s repository has changed
- Check whether distribution of the library has ended
- Check Gradle Offline mode
- Run Gradle Sync
- Retrieve the dependencies again with
--refresh-dependencies - If you are using Version Catalog, check
libs.versions.toml - For plugins, check the repository settings in
pluginManagement
Important:
“Could not find” is an error indicating that Gradle searched for the specified dependency but could not find it.
First, check the library name and version displayed in the error, and then check which repository currently distributes that library.
Summary
The Android Studio Gradle
“Could not find”
error is displayed when Gradle cannot find a specified dependency, such as a library or plugin, in the configured repositories.
The cause may not only be an incorrect library name or version, but also missing repository settings, a change in the distribution location, the end of distribution, or Gradle Offline mode.
First, check the dependency displayed after
Could not find,
and then check the library name, version, and repository in that order to efficiently narrow down the cause.
