Android Studio solve the problem of slow download Gradle

Brief reasons

Android Studio project when first created, the default file is the foreign site to download from google and jcenter needed, so the download speed is slow, sometimes even time out.
For Gradle tools, we can manually download and add to .gradle folder; For online Sync Gradle, just add to the profile of Ali cloud provides domestic mirroring can be effectively addressed.

Solution

First, resolve Download Gradle slow

① Open Scripts in Gradle gradle-wrapper.properties file, view the current project depends Gradle version number
View project depends Gradle version number
② Click Gradle official download , find the corresponding version manually downloaded to the local, the final copy this archive to C: \ Users \ user name .gradle \ wrapper \ dists \ gradle- xxx-all \ xxxxxxx the
Archive copy
Android Studio after the step of detecting the compressed packet has been downloaded, the download will be skipped.

Second, the solution Gradle Sync slow

Open the Scripts in the Gradle the build.gradle file, respectively buildscript and allprojects in repositories adding a first row

maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}

As shown in the following figure:
Add Ali cloud images
this is updated each dependent files, Android Studio will give priority to download dependencies from Ali cloud servers, the speed will be doubled.


Note:
① above operation performed, try to temporarily close the Android Studio Gradle Sysn (software can also exit). After the operation is complete, if Gradle Sysn is interrupted and no longer automatically initiate a search, simply click on the top right corner of Sysn Project with Gradle Files button.
Synchronization Gradle
When adding a mirror without deleting ② google () and jcenter (), this may result in an exception.

Published 48 original articles · won praise 4 · Views 6131

Guess you like

Origin blog.csdn.net/Knightletter/article/details/101074466