1. 程式人生 > >解決Unknown host 'jcenter.bintray.com'問題

解決Unknown host 'jcenter.bintray.com'問題

轉自 解決Unknown host ‘jcenter.bintray.com’問題
1、如圖報錯

2、原因:

build.gradle中jcenter()或maven()被牆了。

3、解決:

方法一:

使用開源中國的maven庫:

阿里雲的:http://maven.aliyun.com/nexus/content/groups/public/

在專案根目錄下的build.gradle中新增如下:

buildscript {

    repositories {
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'
} google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'
} google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }

同時,放在jcenter()前,保證先訪問maven中的連結。

方法二:

jcenter()所訪問的連結是:https://jcenter.bintray.com/

修改https為 http協議下載,即:http://jcenter.bintray.com/

buildscript {

    repositories {
        google()
        jcenter(){url 'http://maven.aliyun.com/nexus/content/groups/public/'
} } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter(){url 'http://maven.aliyun.com/nexus/content/groups/public/'} } } task clean(type: Delete) { delete rootProject.buildDir }

方法二親測無效。。。。

但有時候確實可以通過http://jcenter.bintray.com/訪問到遠端倉庫。