Error:Cannot resolve external dependency xxx:xxx because no respositories are defined.

最近在接觸一個gradle構建方式的老項目時,編譯項目時出現如標題所示錯誤

然後在網上找了一堆答案也沒有找到正確的解決辦法,後面仔細研究了一下gradle.build配置文件,

buildscript {
   ......
 }
apply plugin: 'java'
apply plugin: 'application'
 


jar {
    baseName = 'xxx'
    version =  '0.1.0'
}

dependencies {
    compile "xxx:xxx:xxx"
    .......
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

發現模塊中少了repositories配置項,然後在buildscript{}塊中和頂級配置中分別配置了repositories配置項,問題解決.

buildscript {
   repositories {
      mavenCentral()
  }
apply plugin: 'java'
apply plugin: 'application'
 
repositories {
    mavenCentral()
}

jar {
    baseName = 'xxx'
    version =  '0.1.0'
}

dependencies {
    compile "xxx:xxx:xxx"
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章