2015-06-11 82 views
5

這裏是我的應用模塊「應用」的gradle建設如何看起來像:搖籃插件「com.android.library」不自定義Maven倉庫搜索

apply plugin: 'com.android.application' 

repositories { 
    maven { url 'http://localhost:8080/repository/internal/' } 
} 

... 

dependencies { 
    compile 'org.apache.httpcomponents:httpmime:4.2.3' 
    compile 'com.testpackage.networking:networking:1.0.3' 
} 

和它工作得很好。我試圖在名爲'librarymodule'的庫模塊中使用相同的依賴項。下面是它的build.gradle的樣子:

apply plugin: 'com.android.library' 

repositories { 
    maven { 
     url 'http://localhost:8080/repository/internal/' 
    } 
} 

... 

dependencies { 
    compile 'org.apache.httpcomponents:httpmime:4.2.3' 
    compile 'com.testpackage.networking:networking:1.0.3' 
} 

唯一的區別是gradle這個插件「com.android.library」這裏使用VS在「應用」模塊中使用「com.android.application」。

Error:A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.testpackage.networking:networking:1.0.3. Searched in the following locations: https://jcenter.bintray.com/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom https://jcenter.bintray.com/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar file:/Users/myusername/Library/Android/sdk/extras/android/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom file:/Users/myusername/Library/Android/sdk/extras/android/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar file:/Users/myusername/Library/Android/sdk/extras/google/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom file:/Users/myusername/Library/Android/sdk/extras/google/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar Required by: LibrariesApplication:app:unspecified > LibrariesApplication:librarymodule:unspecified

所以,出於某種原因沒有http://localhost:8080/repository/internal/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom搜索在以下位置列表下。

這不僅是我的存儲庫問題。我能夠例如使用

maven { url 'https://mint.splunk.com/gradle/' } 

庫與依賴

compile 'com.splunk.mint:mint:4.1' 

但還是收到類似的錯誤

有誰知道如何解決這個問題?

回答

2

這有點奇怪,但向root build.gradle的'allprojects'添加自定義存儲庫實際上工作!

allprojects { 
    repositories { 
     jcenter() 

     maven { 
      url 'http://localhost:8080/repository/internal/' 
     } 
    } 
} 
+0

這讓我解決一個行家回購罐子的依賴度在尋找另一 –

-1

如果你不想把maven的憑據在項目文件(和你不應該)在你的home目錄下創建一個「gradle.properties」文件,並把maven的證書在該文件,如:

mavenUser=myUser 
mavenPassword=myPassword 

然後,在你的build.gradle文件,使用方法如下:

maven { 
    credentials { 
     username mavenUser 
     password mavenPassword 
    } 
    url http://my.maven.url 
}