Android AS Unknown host 'jcenter.bintray.com' 问题 开启阿里镜像

1,512 阅读1分钟

今天重装系统后,as运行一直报 Unknown host 'jcenter.bintray.com' 错误, 百度后发现是连接不上没法下载仓库文件,可恶的墙。-_-||

解决方法:

使用阿里仓库服务、 在根目录下build.gradle 添加 maven { url 'maven.aliyun.com/repository/…'} 然后build 一下、就可以 了

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'https://jitpack.io' }
        mavenCentral()
    }
    dependencies {
         classpath 'com.android.tools.build:gradle:3.0.1'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'https://jitpack.io' }
    }
}

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