我准备学习android开发,于是下载了android studio。
但是用android studio新建了一个empty activity项目后,下载jar包奇慢无比。查资料后知道了需要配置build.gradle.
在这里插入图片描述

// Top-level build file where you can add configuration options common to all sub-projects/modules.
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {

        // 添加阿里云 maven 地址
        maven {
            allowInsecureProtocol = true
            url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven {
            allowInsecureProtocol = true
            url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }

        // jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
}





task clean(type: Delete) {
    delete rootProject.buildDir
}

其中plugins和task是项目创建好就有的,其它的则是我添加的。

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

maven中要加allowInsecureProtocol = true。不然它不让你使用http,只准使用https。

maven {
            allowInsecureProtocol = true
            url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }

配置好后,gradle就会从阿里云下载jar包,速度会非常快。

我使用的android studio版本:
在这里插入图片描述

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐