An error when building pytorch for android

Following this guide: Making Native Android Application that uses PyTorch prebuilt libraries — PyTorch Tutorials 1.12.0+cu102 documentation
Using gradle 4.10.3 and JDK 10 I got an error:

Install the project...
-- Install configuration: "Release"
Installation completed, now you can copy the headers/libs from /mnt/d/pytorch/build_android_arm64-v8a/install to your Android project directory.
+ echo 'arm64-v8a build output lib,include at /mnt/d/pytorch/build_android_arm64-v8a/install'
arm64-v8a build output lib,include at /mnt/d/pytorch/build_android_arm64-v8a/install
+ ln -s /mnt/d/pytorch/build_android_arm64-v8a/install/lib /mnt/d/pytorch/android/pytorch_android/src/main/jniLibs/arm64-v8a
+ ln -s /mnt/d/pytorch/build_android_arm64-v8a/install/include /mnt/d/pytorch/android/pytorch_android/src/main/cpp/libtorch_include/arm64-v8a
+ '[' true = true ']'
+ /mnt/d/pytorch/android/gradlew -PABI_FILTERS=arm64-v8a -p /mnt/d/pytorch/android assembleRelease

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all artifacts for configuration ':app:classpath'.
   > Could not resolve com.android.tools.build:gradle:4.1.2.
     Required by:
         project :app
      > Could not resolve com.android.tools.build:gradle:4.1.2.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
                  > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      > Could not resolve com.android.tools.build:gradle:4.1.2.
         > Could not get resource 'https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
                  > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

I tried to edit the build.gradle file to relace https with http but it didn’t help. How can I solve this problem?