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 \'act
I tried all solution here but none is working, then I realise I made a mistake, I put the .aar
in wrong folder, as you can see below, I thought I should put in root folder, so I created a libs
folder there (1 in picture), but inside the app folder, there is already a libs
, you should put in second libs
, hope this help those who has same issue as mine:
Please follow below steps to get it working ( I have tested it up to Android Studio 2.2)
Lets say you have kept aar file in libs folder. ( assume file name is cards.aar
)
then in app build.gradle
specify following and click sync project with Gradle files.
Open Project level build.gradle and add flatDir{dirs 'libs'}
like did below
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
and now open app level build.grdle file and add .aar
file
dependencies {
implementation(name:'cards', ext:'aar')
}
If everything goes well you will see library entry is made in build -> exploded-aar
Also note that if you are importing a .aar file from another project that has dependencies you'll need to include these in your build.gradle, too.
Add below line in app level build.gradle
implementation fileTree(dir: "libs", include: ["*.aar"])
Change Project structure from Android to Project.
Navigaate to app->libs as below
Then paste "aar" in libs folder.
Click on File at top left of android studio and click "Sync Project with Gradle Files" as below.
That's it.
UPDATE ANDROID STUDIO 3.4
before(default)
implementation fileTree(include: ['*.jar'], dir: 'libs')
just add '*.aar'
in include
array.
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
it works well on Android Studio 3.x.
if you want ignore some library? do like this.
implementation fileTree(include: ['*.jar', '*.aar'], exclude: 'test_aar*', dir: 'libs')
debugImplementation files('libs/test_aar-debug.aar')
releaseImplementation files('libs/test_aar-release.aar')