Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use local aar dependency?

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?

like image 988
cs x Avatar asked Mar 05 '15 02:03

cs x


People also ask

How do I add a dependency in gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.


2 Answers

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

like image 124
Sandy D. Avatar answered Oct 25 '22 11:10

Sandy D.


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 } 
like image 29
Sandro Simas Avatar answered Oct 25 '22 11:10

Sandro Simas