Android Studio关于下载某Jar包网络超时问题

1.首先将Android Studio的Settings打开,然后搜索Android Studio将Enable embedded Maven repository选项勾选,你也可以通过单击Build Execution Deployment中的Gradle来找到Android Studio选项

[点击并拖拽以移动] ​可通过此图来找到勾选项

2.修改build.gradle文件 如下,其中的注解为核心修改部分

buildscript {
    repositories {
       //将jcenter()注释掉,加入先面maven{url'....'}
       // jcenter()
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.mob.sdk:MobSDK:+'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
     //将jcenter()注释掉,加入先面maven{url'....'} 还有加入下面的maven { url "https://jitpack.io" }
     //   jcenter()
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven { url "https://jitpack.io" }

    }
    tasks.withType(Javadoc) {
        options {
            encoding "UTF-8"
            charSet 'UTF-8'
            links "http://docs.oracle.com/javase/7/docs/api"
        }
    }
}

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

3、如果build.gradle中google()报某某错误的话,可以使用如下代码替换

maven {url 'https://maven.google.com'}

猜你喜欢

转载自blog.csdn.net/weixin_40441128/article/details/83477633
今日推荐