'What is the fix for could not resolve com.android.tools.build:gradle:4.0.1. in flutter vscode?

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':audioplayers'.

Could not resolve all artifacts for configuration ':audioplayers:classpath'. Could not resolve com.android.tools.build:gradle:4.0.1. Required by: project :audioplayers > Could not resolve com.android.tools.build:gradle:4.0.1. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'. > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'. > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.2/userguide/build_environment.html#gradle_system_properties > Remote host terminated the handshake Failed to notify project evaluation listener. Could not get unknown property 'android' for project ':audioplayers' of type org.gradle.api.Project. Could not find method implementation() for arguments [project ':path_provider'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.



Solution 1:[1]

Need to enable other protocol versions for fetching from Maven repo, add the following

allowInsecureProtocol = true

in your project build.gradle file

  repositories {
        google()
        mavenCentral(){
            allowInsecureProtocol = true
        }
    }

Solution 2:[2]

This error when happening the android studio can not update the Gradle file from their servers see this link to solve here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ked
Solution 2 Mohammad Mirshahbazi