Every time Android studio opens a new project build-gradle, there is a problem solution

Every time Android studio opens a new project build-gradle, there is a problem solution



Today the senior taught a very practical operation of Android Studio! ! !

Problem Description

  When working on Android projects, one of the problems that I often encounter is to open a new project and download gradle in various ways, which is very, very slow, and download errors often! The practical experience is extremely poor! !
Similar errors are as follows (various):

Insert picture description here

Insert picture description here

wrong reason

  What caused our Android Studio to announce build failed after downloading after a long period of effort?

  After opening any project with Android Studio, open the build.gradle file:


Insert picture description here
Insert picture description here
  Good guys! The download sources used are all Google. Domestic users cannot use Google. Most of the download sources are blocked (unless fq). What should I do?
  When I scratched my head and didn't know what to do, the senior saw it for me in one minute, hahahahaha, cool!

Solution

  Add a domestic mirror source, look at the picture! ,

Insert picture description here
  Modify the following statement in the build.gradle file:

maven {
    
     url 'https://maven.aliyun.com/repository/gradle-plugin' } //gradle 国内镜像仓
maven {
    
     url 'https://maven.aliyun.com/repository/google' } //google 国内镜像仓
maven {
    
     url 'https://maven.aliyun.com/repository/jcenter' } //jcenter 国内镜像仓

Finally, rebuild, and you can start Android operation happily!

At last

  I've read it all here. Dear readers, leave your valuable likes and comments. This will be my firm motivation to move on! ! !
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45386875/article/details/114952530