MeWrite Docs

Could not resolve all dependencies for configuration

Gradleで依存関係の解決に失敗した場合に発生するエラー

概要

Could not resolve all dependencies for configuration は、Gradleが依存関係をダウンロードまたは解決できない場合に発生するビルドエラーです。

エラーメッセージ

Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.example:library:1.0.0.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not download artifact.jar (com.example:library:1.0.0)
   > Could not get resource 'https://repo.maven.apache.org/maven2/...'

原因

1. 依存関係が存在しない

1
2
3
dependencies {
    implementation 'com.example:nonexistent:1.0.0'
}

2. リポジトリが設定されていない

1
2
3
4
// リポジトリの設定漏れ
repositories {
    // mavenCentral() がない
}

3. バージョンの競合

1
2
3
4
dependencies {
    implementation 'com.google.guava:guava:30.0-jre'
    implementation 'com.example:library:1.0.0' // guava 28.0 を要求
}

4. ネットワーク接続の問題

プロキシやファイアウォールが原因の場合があります。

解決策

1. リポジトリを追加

1
2
3
4
5
6
// build.gradle
repositories {
    mavenCentral()
    google()
    maven { url 'https://jitpack.io' }
}

2. Gradleキャッシュをクリア

1
2
3
4
5
6
7
8
# Gradleキャッシュを削除
rm -rf ~/.gradle/caches

# プロジェクトのビルドディレクトリを削除
./gradlew clean

# 依存関係を再ダウンロード
./gradlew build --refresh-dependencies

3. バージョンを強制指定

1
2
3
4
5
configurations.all {
    resolutionStrategy {
        force 'com.google.guava:guava:30.0-jre'
    }
}

4. プロキシ設定

1
2
3
4
5
# ~/.gradle/gradle.properties
systemProp.http.proxyHost=proxy.example.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.example.com
systemProp.https.proxyPort=8080

5. オフラインモードを無効化

1
2
3
4
5
# Android Studioの場合:
# File > Settings > Build > Gradle > Offline work のチェックを外す

# コマンドラインの場合
./gradlew build --no-offline

6. 依存関係ツリーを確認

1
2
3
4
5
# 依存関係ツリーを表示
./gradlew dependencies

# 特定の設定のみ
./gradlew dependencies --configuration compileClasspath

7. JitPack経由でGitHubリポジトリを使用

1
2
3
4
5
6
7
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.User:Repo:Tag'
}

Android固有の問題

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// build.gradle (Project)
buildscript {
    repositories {
        google()  // 必須
        mavenCentral()
    }
}

allprojects {
    repositories {
        google()  // 必須
        mavenCentral()
    }
}

関連エラー

関連エラー

Java の他のエラー

最終更新: 2025-12-17