How to import a .aar file into Android Studio 1.1.0 and use it in my code
To import an .aar library:
- Go to File>New>New Module
- Select "Import .JAR/.AAR Package" and click next.
- Enter the path to the .aar file and click finish.
- Go to File>Project Structure (Ctrl+Shift+Alt+S).
- Under "Modules," in left menu, select "app."
- Go to "Dependencies" tab.
- Click the green "+" in the upper right corner.
- Select "Module Dependency"
- Select the new module from the list.
After reading a lot of answers on Stackoverflow, I found the solution for my problem, I want you to know which were the steps I followed in order to reproduce it:
- Add a .aar file in my libs folder.
- Use "New Module" option under File menu.
- Import the .aar file.
- Build gradle and compile the project.
When I tried to use the new module in my app, It didn't recognize any class inside the new module.
The problem is related to the version of Gradle, I was using 1.1.0 and there is a bug in this version, so my suggestion is to change the version to 1.0.1, there is an Issue already open in order to fix this problem https://code.google.com/p/android/issues/detail?id=162634
You should change the version in the build.gradle file located in the root of your project.
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
You can find additional information about this problem here https://groups.google.com/forum/#!topic/adt-dev/1Ho_c8dALQQ
I guess in version 1.2.0 this problem will be solved.