Fixing Gradle TLS handshake_failure on Maven Central (Android Builds)

Fixing Gradle TLS handshake_failure on Maven Central (Android Builds)

Leader posted Originally published at dev.to 1 min read

If your Android native build is constantly failing with a TLS handshake error when trying to download dependencies from Maven Central, the root cause might be an invisible environment variable polluting your Java settings.

The most frustrating part of this error is that your local internet connection is usually completely fine.

The Quick Diagnosis

Open your terminal and test the connection directly to the Maven repository using curl:

curl -I https://repo1.maven.org/maven2/

If curl connects successfully and returns an HTTP 200, but your Gradle build still throws a Received fatal alert: handshake_failure, your network is not the problem. Gradle itself is failing to establish the secure line.

The Root Cause

An environment variable called GRADLE_OPTS is likely injecting broken SSL or JSSE flags into your build process. Specifically, flags like -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT force Gradle to look at system-specific certificate stores that conflict with standard Java behavior, breaking the handshake completely.

The Fix

To resolve this permanently, you need to wipe out the polluted configuration so Gradle can fall back to its clean JDK defaults.

  1. Open your system Environment Variables settings.
  2. Check both the User variables and the System/Machine variables.
  3. Look for GRADLE_OPTS.
  4. Delete the variable entirely from both locations.
  5. Close your IDE, restart your terminal, and run your build again.

Once those injected flags are gone, Gradle will use standard JDK defaults, and your dependency downloads will start succeeding immediately.


I've been spending a lot of my spare time building out a diagnostic tool over at FixMyError to map out environment bugs like this automatically. I just put a live, free sandbox preview on the homepage if you want to see how the engine breaks down terminal stack traces before you ever make an account.

More Posts

React Native Quote Audit - USA

kajolshah - Mar 2

How to fix "Gradle build daemon disappeared unexpectedly" in React Native & Expo

Asta Silva - May 25

React Native Android Autolinking Issues: Common Problems and What to Check

Asta Silva - Apr 6

Gradle build errors in React Native: what usually wastes the most time

Asta Silva - Apr 6

Why React Native Builds Break After Updating Dependencies (And How to Fix It)

Asta Silva - Apr 19
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

8 comments
5 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!