日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

AndroidStudio編譯報錯 Connect to repo.maven.apache.org:443

作者:會游泳的貓! 更新時間: 2022-08-30 編程語言

首先需要知道的是:

1.連接錯誤的原因是因為沒有正確上網導致的maven相關的資源拉不下來,沒有梯子,就使用國內的開源網址

2. gradle插件版本號在7.0之后,build.gradle和settings.gradle配置容易重復,導致報錯:

Build was configured to prefer settings repositories over project repositori…

解決方案

1.把settings.gradle的dependencyResolutionManagement整體注釋,settings.gradle完整代碼:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
//dependencyResolutionManagement {
//    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
//    repositories {
//        google()
        mavenCentral()
//       maven {
//            url 'https://maven.aliyun.com/repository/central/'
//       }
//    }
//}
rootProject.name = "xxx"
include ':app'
include ':aidlaar'

2.在build.gradle中添加別的開源網址,完整代碼:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter() // Warning: this repository is going to shut down soon

        //添加各種源
        maven {
            url 'https://maven.aliyun.com/repository/central/'
        }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
        maven {
            url "https://jitpack.io"
        }
        maven {
            url "https://dl.bintray.com/lukaville/maven"
        }
        maven {
            url "https://maven.google.com/"
        }
    }
}

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

原文鏈接:https://blog.csdn.net/ABCDEF123236/article/details/124683545

欄目分類
最近更新