美文网首页
AndroidStudio 工具使用问题

AndroidStudio 工具使用问题

作者: 洪荒之气 | 来源:发表于2023-11-01 15:59 被阅读0次

    一、进行项目SDK下载出现超时失败
    (一)解决方法1:AndroidStudio切换到project > gradle > wrapper > gradle_wrapper.properties
    > 把 distributionUrl 中的https 改成 http ,然后 Try Again。但是可能会失败,因为
    AndroidStudio 好像不支持http的下载方式。所以,复制 distributionUrl 中的URL ,然后把
    https 改成http之后,复制到浏览器中进行单独下载,下载好的SDK包放到如下目录中:
    C:\Users\Administrator.gradle\wrapper\dists\gradle-x.x-all\ ,然后点击Try Again。
    (二)解决方法2:打开项目根目录下的setting.gradle,在dependencyResolutionManagement和pluginManagement 中加入阿里云镜像,用阿里云镜像下载,阿里云镜像代码如下:

    【参考文章地址】
    1、https://zhuanlan.zhihu.com/p/608337942
    2、https://blog.csdn.net/zhong_zihao/article/details/121273146

    【版本一】
    buildscript {
    ext.kotlin_version = "1.5.10"
    repositories {
    maven {url 'https://maven.aliyun.com/repository/public/'}
    maven {url 'https://maven.aliyun.com/repository/google/'}
    maven {url 'https://maven.aliyun.com/repository/central/'}
    maven {url 'https://maven.aliyun.com/repository/gradle-plugin/'}
    mavenLocal()
    mavenCentral()

    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    }

    allprojects {
    repositories {
    maven {url 'https://maven.aliyun.com/repository/public/'}
    maven {url 'https://maven.aliyun.com/repository/google/'}
    maven {url 'https://maven.aliyun.com/repository/central/'}
    maven {url 'https://maven.aliyun.com/repository/gradle-plugin/'}
    mavenLocal()
    mavenCentral()
    }
    }

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

    【版本2】
    pluginManagement {
    repositories {
    // 改为阿里云的镜像地址
    maven { setUrl("https://maven.aliyun.com/repository/central") }
    maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
    maven { setUrl("https://maven.aliyun.com/repository/google") }
    maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
    maven { setUrl("https://maven.aliyun.com/repository/public") }
    maven { setUrl("https://jitpack.io") }
    gradlePluginPortal()
    google()
    mavenCentral()
    }
    }
    dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
    // 改为阿里云的镜像地址
    maven { setUrl("https://maven.aliyun.com/repository/central") }
    maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
    maven { setUrl("https://maven.aliyun.com/repository/google") }
    maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
    maven { setUrl("https://maven.aliyun.com/repository/public") }
    maven { setUrl("https://jitpack.io") }
    google()
    mavenCentral()
    }
    }
    rootProject.name = "DN_Compose"
    include ':app'

    相关文章

      网友评论

          本文标题:AndroidStudio 工具使用问题

          本文链接:https://www.haomeiwen.com/subject/xbcgidtx.html