Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle refuses a repository that uses http:// instead of https://

ErrorThe build fails on a repository whose url starts with http://

Short answer

Gradle does not talk to a repository over plain HTTP unless that repository opts in. Find the repository whose url starts with http://, switch it to https:// if the server supports it, or set allowInsecureProtocol to true inside that one repository block. There is no global switch.

  • Applies to Gradle 8.x, Gradle 9.x, Android Gradle Plugin 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List every repository URL in the build files. Any line that starts with http:// is a candidate, including the ones in settings and in buildscript blocks.

    grep -rn --include=*.gradle --include=*.gradle.kts --include=*.properties "http://" .
  2. 2Match what you see, then jump to its fix

    1. 1The grep above prints a maven { url ... } line with http://A repository is declared with an http:// URLFix
    2. 2A property such as allowInsecureProtocol sits in gradle.properties or ~/.gradle/gradle.properties and the error is unchangedYou tried to switch the check off for the whole buildFix

What does the error look like?

  • The build fails on a repository whose url starts with http://
  • Android Studio sync fails while resolving a dependency from a self-hosted or LAN Maven repository
  • Setting allowInsecureProtocol in gradle.properties changes nothing

Cause 1 of 2

A repository is declared with an http:// URL

1Check

Open the file and the block that grep found. The same address may be declared more than once: in settings.gradle, in the root build file, in a buildscript block and in a module.

grep -rn -B2 -A3 "http://" settings.gradle* build.gradle* app/build.gradle*

2Fix

First try the https:// form of the same address. If the server only speaks HTTP (an internal host, for example), opt in on that repository only. Gradle documents this as a per-repository choice.

// Kotlin DSL
maven {
    url = uri("http://repo.internal.example:8081/releases")
    isAllowInsecureProtocol = true
}

// Groovy DSL
maven {
    url "http://repo.internal.example:8081/releases"
    allowInsecureProtocol = true
}

3Verify

Sync or run a build that resolves a dependency from that repository.

./gradlew build --refresh-dependencies

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 2

You tried to switch the check off for the whole build

1Check

Search the Gradle properties files for the name. Gradle says it intentionally has no global system or Gradle property that disables this check, so such a line has no effect.

grep -n -i "insecure" gradle.properties ~/.gradle/gradle.properties

2Fix

Delete the property and set the flag on each repository that needs it, as in the first cause. Prefer moving the repository to HTTPS: the Gradle reference warns that plain HTTP lets a man-in-the-middle impersonate the server and serve malicious code.

# remove any line like this from gradle.properties
# allowInsecureProtocol=true

3Verify

Run the build again; the repository is now accepted because of its own flag.

./gradlew build

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Serve every internal Maven repository over HTTPS with a real or internal-CA certificate, so no flag is needed.
  • Keep all repository declarations in one place (dependencyResolutionManagement in settings) so there is one URL to change.
  • Review any build change that adds allowInsecureProtocol; it should name one host, not a wildcard habit.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.