Gradle “peer not authenticated” Error

If you see the following error while trying to automatically integrate PSPDFKit using Gradle, it is probably caused by using an outdated JDK (Java Development Kit) inside Android Studio:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not download pspdfkit.aar (com.pspdfkit:pspdfkit:x.y.z)
 > Could not get resource 'https://my.pspdfkit.com/maven/com/pspdfkit/pspdfkit/x.y.z/pspdfkit-x.y.z.aar'.
  > Could not GET 'https://my.pspdfkit.com/maven/com/pspdfkit/pspdfkit/x.y.z/pspdfkit-x.y.z.aar'.
   > peer not authenticated

The PSPDFKit Maven repository requires Gradle to communicate securely using TSL 1.2, which is disabled in JDK versions prior to JDK 8. See this issue on the JDK bug tracker.

How to Fix the “peer not authenticated” Error

  • Download and install JDK 8 for your local development machine. You can find the current version at the Oracle JDK download page.

  • Inside Android Studio, open your affected project.

    • Go to File > Project Structure.

    • Click the SDK Location tab.

    • Select your locally installed JDK 8 directory as the JDK location.

      • On macOS: Run /usr/libexec/java_home --version 1.8 within the terminal, which will output the correct JDK folder.

      • On Windows: Run for %i in (javac.exe) do @echo. %~$PATH:i in the command line, and select the correct JDK 8 folder.

    • Confirm your changes by pressing OK.

  • Rebuild your project and verify that the error is resolved.