[英]Gradle Sync Issue when I try to build and run code from a GitHub repository
[英]Gradle and github repository, slow sync
從今天早上開始,我在Android Studio上的android項目中遇到了一個奇怪的問題。 Gradle同步非常慢。 我搜索發現這是由於github存儲庫所致。
我設法用這個build.gradle在新的android studio項目上重現此錯誤
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
maven { url 'https://raw.githubusercontent.com/bbbenja/mvn-repo/master/' }
mavenCentral()
}
}
Github改變了對原始文件的策略? 有人有同樣的問題嗎?
謝謝
我只是遇到了同樣的問題-我們無法構建整個Android項目,因為我們依賴Github托管的mvn存儲庫。
Github似乎有問題。 似乎他們的“原始”托管無效。
這是我的臨時解決方法:
1)Git在本地克隆倉庫
2)在本地使用MAMP或其他Web服務器,將其指向下載mvn-repo文件夾的位置
3)在您的構建文件中,根據您的Web服務器將其設置為localhost ...
例如,這是我們的build.gradle現在的樣子:
repositories {
// this maven repo is a source for the compile dependencies
//maven { url 'https://github.com/Goddchen/mvn-repo/raw/master/'}
//temporary workaround
maven { url 'http://localhost:8888/' }
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
flatDir name: 'libs', dirs: "libs"
}
無需在本地克隆git repo,您所需要做的就是通過遵循本機Gradle支持來過濾存儲庫提取
存儲庫到依賴項匹配
現在可以將存儲庫與依賴項進行匹配,這樣,如果永遠不會在存儲庫中找到依賴項,那么Gradle就不會在存儲庫中搜索依賴項。
例:
repositories {
maven {
url "https://repo.mycompany.com"
content {
includeGroupByRegex "com\\.mycompany.*"
}
}
}
供進一步參考Gradle 5.1.1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.