首页 > 解决方案 > mavenLocal 没有从 .m2 存储库中获取工件

问题描述

我已将 maven publish 添加到运行正常的库项目中,并且它正在 .m2/repository 中生成 .aar 文件现在我正在尝试将该库添加到我的应用程序项目中,但它给出了错误。

这是我的 build.gradle(app's)

buildscript {
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.6.1'
    classpath 'com.google.gms:google-services:4.3.3'
    classpath 'com.google.firebase:perf-plugin:1.3.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    mavenLocal()
    mavenCentral()
    google()
    jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

和 common.gradle (我在哪里实现了那个库)像这样

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Use project(":libraryName") if you need to test changes to library in development.
 implementation project(":libraryName")
 }

我得到的错误

 ERROR: Unable to resolve dependency for ':mobile@prodDebugUnitTest/compileClasspath': Failed to transform artifact 'library.aar (project :libraryName)' to match attributes {artifactType=jar}.

标签: androidmavenandroid-studiogradle

解决方案


尝试包括*.aar

implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

或者你可以像这样实现:

implementation "com.yourlibrarygroup.id:artifactoryname:0.0.1@aar"

推荐阅读