Home How to manually include external aar package using new Gradle Android Build System

# How to manually include external aar package using new Gradle Android Build System

user8871
1#
user8871 Published in September 20, 2018, 1:06 pm

I've been experimenting with the new android build system and I've run into a small issue. I've compiled my own aar package of ActionBarSherlock which I've called 'actionbarsherlock.aar'. What I'm trying to do is actually use this aar to build my final APK. If I include the whole ActionBarSherlock library as an android-library module to my main project using compile project (':actionbarsherlock') I'm able to build successfully without any problems.

But my problem is that I want to provide that dependency as a aar file package MANUALLY just if I would a JAR then I can't seem to figure out how to properly include it into my project. I've attempted to use the compile configuration but this doesn't seem to work. I keep on getting cannot find symbol during compile which tells me that the classes.jar from aar package isn't getting included in the classpath.

Does anyone know of the syntax to manually include an aar package as a file?

buildscript {

repositories {
mavenCentral()
}
dependencies {
}
}
apply plugin: 'android'

repositories {
mavenCentral()
}
dependencies {
compile files('libs/actionbarsherlock.aar')
}

android {
compileSdkVersion 15
buildToolsVersion "17.0"
}


EDIT: So the answer is that it's not currently supported, here's the issue if you want to track it.

EDIT: Currently as this is still not supported directly the best alternative seems to be the proposed solution from @RanWakshlak

EDIT: Also simpler by using the syntax proposed by @VipulShah

• Consider Vipul Shah's response: it finally worked for me, without local maven repository, as of Android Studio 0.5.8. – shkschneider May 12 '14 at 13:34
• Take a look at my question and answer here stackoverflow.com/a/31662782/746347 – mixel Jul 27 '15 at 20:36
• If you are using Gradle 3.0.0 or higher, this simple Gradle setup worked for me: stackoverflow.com/questions/29081429/… – user1506104 May 3 at 4:02