0

I have added maven publish to my library project that is working fine and it's generating .aar file inside .m2/repository Now I am trying to add that library into my app project but it give errors.

here's my 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
}

and common.gradle (where I implemented that library) like this

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

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

Errors I am getting

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

1 Answers1

1

try to include *.aar

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

or you can implement like this :

implementation "com.yourlibrarygroup.id:artifactoryname:0.0.1@aar"
mzennis
  • 103
  • 1
  • 5
  • have you tried this https://stackoverflow.com/questions/16682847/how-to-manually-include-external-aar-package-using-new-gradle-android-build-syst ? – mzennis Apr 01 '20 at 18:01
  • Manually coping aar is working if I copy aar file from .m2 and paste it to library module. but as I am using maven publish I want to eliminate that manual process – Radhey.g Apr 01 '20 at 18:05
  • 1
    I have given try to that solution but it wasn't working but thanks to you pointing it again I found out my groupid is different then what I was passing. now it's working fine. – Radhey.g Apr 01 '20 at 18:39
  • glad if it helps :) – mzennis Apr 02 '20 at 03:14