android - FLUTTER Unable to resolve dependencies in Flutter project due to Gradle task failure - Stack Overflow

admin2025-04-22  0

I am facing an issue while running my Flutter application on an emulator. During the build process, I encounter the following error:

Launching lib/main.dart on sdk gphone16k x86_64 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b
      > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
         > Could not get resource '.4.5/relinker-1.4.5.pom'.
            > Could not GET '.4.5/relinker-1.4.5.pom'.
               > repo.maven.apache

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at .

BUILD FAILED in 1s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #1, wait time: 100ms

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b
      > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
         > Could not get resource '.4.5/relinker-1.4.5.pom'.
            > Could not GET '.4.5/relinker-1.4.5.pom'.
               > repo.maven.apache

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at .

BUILD FAILED in 1s
[!] Gradle threw an error while downloading artifacts from the network.
Error: Gradle task assembleDebug failed with exit code 1

Exited (1).

I tried the following to resolve the issue:

  • Changed the Gradle version.
  • Ran flutter clean and flutter pub get.
  • Restarted the emulator. Despite these steps, the error persists. I am unable to find any solutions that work. Can someone assist me with resolving this dependency issue?

Device Specs:

  • OS: Ubuntu Linux 22
  • Android Studio Version: 2024.1 Koala
  • Flutter Version: Latest
  • Java Version: 21

Gradle Configuration: app/build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

android {
    namespace = "com.example.library_laravel"
    compileSdk = flutterpileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

    defaultConfig {
        applicationId = "com.example.library_laravel"
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    buildTypes {
        release {
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

settings.gradle:

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.1.0" apply false
    id ".jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"

Flutter Doctor Output:

> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.3, on Ubuntu 24.04.1 LTS 6.8.0-51-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.1)
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
[✓] VS Code (version 1.96.4)
[✓] VS Code (version 1.96.4)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Any guidance on how to fix this issue would be much appreciated!

I expect to identify the cause of the dependency resolution failure, whether it's due to network issues, repository misconfiguration, or incompatible Gradle versions. I also expect guidance on how to fix the problem.

some notifications when create new project When I create a new project there is also a notification like this

flutter create name_project Creating project name_project... Resolving dependencies in name_project... Downloading packages... Got dependencies in name_project. Write 130 files. All done! You can find general documentation for Flutter at: / Detailed API documentation is available at: / If you prefer video documentation, consider: In order to run your application, type: $ cd name_project $ flutter run Your application code is in library_laravel/lib/main.dart. The configured version of Java detected may conflict with the Gradle version in your new Flutter app. To keep the default AGP version Gradle version 8.3, download a compatible Java version (Java 17 <= (Java 17 <= compatible Java version < Java 21) Java version < Java 21). Configure this Java version globally for Flutter by running: flutter config --jdk-dir=<JDK_DIRECTORY> Alternatively, to continue using your configured Java version, update the Gradle version specified in the following file to a compatible Gradle version (compatible Gradle version range: 8.4 - 8.7): /home/user/projects/flutter-project/name_project/android/gradle/wra pper/gradle-wrapper.properties You may also update the Gradle version used by running ./gradlew wrapper --gradle-version=<COMPATIBLE_GRADLE_VERSION>. See .html#java for details on compatible Java/Gradle versions, and see .html#sec:upgrading_wrap per for more details on using the Gradle Wrapper command to update the Gradle version used.

I am facing an issue while running my Flutter application on an emulator. During the build process, I encounter the following error:

Launching lib/main.dart on sdk gphone16k x86_64 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b
      > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
         > Could not get resource 'https://repo.maven.apache./maven2/com/getkeepsafe/relinker/relinker/1.4.5/relinker-1.4.5.pom'.
            > Could not GET 'https://repo.maven.apache./maven2/com/getkeepsafe/relinker/relinker/1.4.5/relinker-1.4.5.pom'.
               > repo.maven.apache.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle..

BUILD FAILED in 1s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #1, wait time: 100ms

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
     Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b
      > Could not resolve com.getkeepsafe.relinker:relinker:1.4.5.
         > Could not get resource 'https://repo.maven.apache./maven2/com/getkeepsafe/relinker/relinker/1.4.5/relinker-1.4.5.pom'.
            > Could not GET 'https://repo.maven.apache./maven2/com/getkeepsafe/relinker/relinker/1.4.5/relinker-1.4.5.pom'.
               > repo.maven.apache.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle..

BUILD FAILED in 1s
[!] Gradle threw an error while downloading artifacts from the network.
Error: Gradle task assembleDebug failed with exit code 1

Exited (1).

I tried the following to resolve the issue:

  • Changed the Gradle version.
  • Ran flutter clean and flutter pub get.
  • Restarted the emulator. Despite these steps, the error persists. I am unable to find any solutions that work. Can someone assist me with resolving this dependency issue?

Device Specs:

  • OS: Ubuntu Linux 22
  • Android Studio Version: 2024.1 Koala
  • Flutter Version: Latest
  • Java Version: 21

Gradle Configuration: app/build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

android {
    namespace = "com.example.library_laravel"
    compileSdk = flutterpileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

    defaultConfig {
        applicationId = "com.example.library_laravel"
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    buildTypes {
        release {
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

settings.gradle:

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.1.0" apply false
    id ".jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"

Flutter Doctor Output:

> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.3, on Ubuntu 24.04.1 LTS 6.8.0-51-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.1)
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
[✓] VS Code (version 1.96.4)
[✓] VS Code (version 1.96.4)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Any guidance on how to fix this issue would be much appreciated!

I expect to identify the cause of the dependency resolution failure, whether it's due to network issues, repository misconfiguration, or incompatible Gradle versions. I also expect guidance on how to fix the problem.

some notifications when create new project When I create a new project there is also a notification like this

flutter create name_project Creating project name_project... Resolving dependencies in name_project... Downloading packages... Got dependencies in name_project. Write 130 files. All done! You can find general documentation for Flutter at: https://docs.flutter.dev/ Detailed API documentation is available at: https://api.flutter.dev/ If you prefer video documentation, consider: https://www.youtube/c/flutterdev In order to run your application, type: $ cd name_project $ flutter run Your application code is in library_laravel/lib/main.dart. The configured version of Java detected may conflict with the Gradle version in your new Flutter app. To keep the default AGP version Gradle version 8.3, download a compatible Java version (Java 17 <= (Java 17 <= compatible Java version < Java 21) Java version < Java 21). Configure this Java version globally for Flutter by running: flutter config --jdk-dir=<JDK_DIRECTORY> Alternatively, to continue using your configured Java version, update the Gradle version specified in the following file to a compatible Gradle version (compatible Gradle version range: 8.4 - 8.7): /home/user/projects/flutter-project/name_project/android/gradle/wra pper/gradle-wrapper.properties You may also update the Gradle version used by running ./gradlew wrapper --gradle-version=<COMPATIBLE_GRADLE_VERSION>. See https://docs.gradle./current/userguide/compatibility.html#java for details on compatible Java/Gradle versions, and see https://docs.gradle./current/userguide/gradle_wrapper.html#sec:upgrading_wrap per for more details on using the Gradle Wrapper command to update the Gradle version used.

Share Improve this question edited Jan 30 at 6:56 Raihan Firdaus asked Jan 29 at 12:33 Raihan FirdausRaihan Firdaus 792 silver badges6 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

The error you are seeing states that it cannot find the version 1.4.5 of the ReLinker dependency:

Could not resolve com.getkeepsafe.relinker:relinker:1.4.5

If you go to the GitHub repository of this dependency, you can see that the latest version is 1.4.4 and it was released a couple years back.

You need to change the version to 1.4.4.

If you need version 1.4.5 of relinker library, you must download it from this repository

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745297969a295083.html

最新回复(0)