47

i google about local aar,every one say it can work,but it don't work at android studio 1.1.0.

i try to use :

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

but it tip:

Warning:Project app: Only Jar-type local dependencies are supported. Cannot handle: /Users/kycq/AndroidStudioProjects/QingTaJiao/app/libs/KycqBasic-release.aar

how should i do to use local aar? if i should use:

compile 'com.example.library:library:1.0.0@aar'

how to do this?

Jonik
  • 80,077
  • 70
  • 264
  • 372
cs x
  • 621
  • 2
  • 8
  • 23

2 Answers2

70

I was getting the same errors.

This was the only thing that helped me:

dependencies {
   compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
 }
repositories{
      flatDir{
              dirs 'libs'
       }
 }

Reference: Adding local .aar files to Gradle build using "flatDirs" is not working

Community
  • 1
  • 1
Sandy D.
  • 3,166
  • 1
  • 20
  • 31
7

In my case a have to distribute an aar. When i import the aar in another project this error appears. I solve this problem distributing the aar with a maven dependency structure (pom, md5, etc...)

publishing {
  publications {
    maven(MavenPublication) {
      groupId "<GROUP_ID>"
      artifactId "<ARTIFACT_ID>"
      version <VERSION>
      artifact "$buildDir/outputs/aar/<AAR_FILE>"
      pom.withXml {
        def dependenciesNode = asNode().appendNode("dependencies")
        configurations.compile.allDependencies.each { dependency ->
          def dependencyNode = dependenciesNode.appendNode("dependency")
          dependencyNode.appendNode("groupId", dependency.group)
          dependencyNode.appendNode("artifactId", dependency.name)
          dependencyNode.appendNode("version", dependency.version)
        }
      }
    }
  }
  repositories {
    maven {
      url "$buildDir/repo"
    }
  }
}

On the android application i need to add the local maven repository:

allprojects {
  repositories {
    jcenter()
    maven {
      url "<LOCAL_REPO>"
    }
  }
}

And add the dependency:

compile("<GROUP_ID>:<ARTIFACT_ID>:<VERSION>@aar") {
  transitive = true
}
Sandro Simas
  • 1,268
  • 3
  • 21
  • 35