摇篮插件“com.android.library'不定制Maven仓库搜索摇篮、仓库、插件、com

2023-09-07 12:05:50 作者:Taurus丶

下面是我的应用程序模块的应用程序建设摇篮的样子:

Here is how my application module 'app' build gradle looks like:

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是这样的:

and it works just fine. I'm trying to use same dependency in my library module named 'librarymodule'. Here is how its build.gradle looks like:

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'
}

的唯一区别是com.android.library这里使用VS在应用程序模块。

The only difference is gradle plugin 'com.android.library' used here vs 'com.android.application' used in 'app' module.

错误:出现在配置项目中的问题:应用程序。   未能解决所有依赖关系配置:应用程序:_debugCompile。   找不到com.testpackage.networking:网络:1.0.3。        搜索在以下位置:            的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        要求:            LibrariesApplication:应用程序:未指定> LibrariesApplication:librarymodule:未指定

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下的搜索在以下位置列表中。

So, for some reason there is no http://localhost:8080/repository/internal/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom under Searched in the following locations list.

这不仅是我的仓库的问题。我可以如使用

It's not only my repository problems. I can for example use

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

与依赖库

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

和仍然得到同样的错误

有谁知道如何解决这个问题?

Does anyone knows how to fix that?

推荐答案

这是一个有点怪,但添加自定义库根build.gradle的allprojects实际工作!

This is a bit strange but adding custom repository to 'allprojects' of root build.gradle actually worked!

allprojects {
    repositories {
        jcenter()

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