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

Viewed 2562

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.

3 Answers

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
        }
    }

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

You may need to specify protocols other than TLSv1.1, TLSv1.2 in gradle.properties.
e.g.

TLSv1.0 SSLv1.0 ...

Example:

systemProp.https.protocols=TLSv1.0,SSLv1.0,SSLv2.0,SSLv3.0
Related