When you first start using Android Studio to create a new project, or when you use other people's projects, you get the error connect time out.
Here are the solutions:
Enter the gradle directory and observe the properties file. Remember your version number. For example, mine is gradle-8.0-all.
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip (Some are bin files, you can change them to all files and change them directly here)
Then go to the official website to download the corresponding gradle version. If it is 8.0-all here, I will download the 8.0-all version (no need to decompress)
Official website link:Gradle Distributions
Because this is an external network, access will be very slow and often cannot be accessed. It is recommended to build a ladder.
If you are also 8.0-all, or you want to use this version you can download mine:
Link: https://pan.baidu.com/s/1X5qlq8-CLefqzvIRcCcRtQ
Extraction code: txdh
After downloading, find the folder shown below
The default is under C:\Users\your username\.gradle\wrapper\dists
Enter the folder of your version. There will be a very complicated file name here. It’s all kinds of weird. It doesn’t matter if it’s different.
Click in and put the file (compressed package) we downloaded into it
Then go back to the Android project and click Try Again, and that’s it!