Method for android studio to set build.gradle as the effective address of Alibaba Cloud

Abstract: When writing a program in android studio, you cannot directly connect to the Google server. Fortunately, Alibaba Cloud provides powerful tool support. This article provides the source code of the settings and a brief explanation.

table of Contents

1. What does the native build.gradle look like?

2. How to make the warehouse accessible

3. Why use so many addresses to replace the word jcenter?

4. What is Alibaba Cloud Cloud Effect?


1. What does the native build.gradle look like?

Open the build.gradle file in the project directory and find that this repositories (meaning warehouse or repository in Chinese) points to jcenter. This jcenter is simply Google's default warehouse address (pro son), but this name represents a long list of addresses, operations (10,000 words omitted).

2. How to make the warehouse accessible

We can't access this jcenter, what should I do? We can use third-party links. This article recommends using Alibaba Cloud Cloud.

The specific code is as follows:

buildscript {
    repositories {  //repositories的意思是仓库、存储库,maven的意思是专家
        // 添加阿里云 maven 地址
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven { url'https://maven.aliyun.com/repository/public/' }
        maven { url'https://maven.aliyun.com/repository/google/' }
        maven { url'https://maven.aliyun.com/repository/jcenter/' }
        maven { url'https://maven.aliyun.com/repository/central/' }
        mavenLocal()
        mavenCentral()
  
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
      }
}
allprojects {
    repositories {
        // 添加阿里云 maven 地址
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven { url'https://maven.aliyun.com/repository/public/' }
        maven { url'https://maven.aliyun.com/repository/google/' }
        maven { url'https://maven.aliyun.com/repository/jcenter/' }
        maven { url'https://maven.aliyun.com/repository/central/' }
        mavenLocal()
        mavenCentral()
 
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

3. Why use so many addresses to replace the word jcenter?

Because jcenter is parsed into a lot of functions by android studio by default, when you compile the program, it will automatically download the dependent library to the specified place, and then unzip it to the specified folder on your computer.

These actions are automated.

Alibaba Cloud's warehouse will not be automatically operated by android studio, so replace a word with a lot of addresses.

Whenever you use it, just fill in the corresponding address.

For example, if "google()" is written in some programs, "https://maven.aliyun.com/repository/google/" is used instead.

No matter so much, just use it, otherwise, when you use it, wait a few hours without moving.

 

4. What is Alibaba Cloud Cloud Effect?

We can visit the URL:

https://maven.aliyun.com/mvn/guide

The picture below is a screenshot of Alibaba Cloud Cloud. Alibaba Cloud Maven Central Warehouse  provides a public agent warehouse for Alibaba Cloud Cloud  Efficiency to help R&D personnel improve the efficiency of R&D and production. Using Alibaba Cloud Maven Central Warehouse as the download source, the speed is faster and more stable.

Specifically, I won't explain it anymore.

Guess you like

Origin blog.csdn.net/youngwah292/article/details/110743407