Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a .aar file into Android Studio 1.1.0 and use it in my code

Tags:

android

I have read a lot answers related to this topic, but none of them have worked to solve my problem, so need help with this:

I need to import a .aar file into a project created with Android Studio 1.1.0, I have imported it using the "New Module" option and actually I don't receive any error, I can build the application and run it, but when I try to use a class from this .aar file Android Studio doesn´t find the reference to it, let's say it can´t recognize the package that I want to include in my code.

You are maybe thinking that I must add the dependency, I have already done that, It seems to not work.

So someone could tell me which is the correct way to import and use a .aar file in Android Studio 1.1.0

like image 643
PoliceEstebi Avatar asked Apr 23 '15 14:04

PoliceEstebi


People also ask

How can add .AAR file in Android Studio?

Add your AAR or JAR as a dependencyNavigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your . aar or .

How do I unpack an .AAR file?

In android studio, open the Project Files view. Find the . aar file and double click, choose "arhcive" from the 'open with' list that pops up. This will open a window in android studio with all the files, including the classes, manifest, etc.

What is .AAR file in Android Studio?

Android Studio can be used to create an Android archive file (*. aar) that can contain classes and methods that make use of Android classes and related files. Like creating the Jar file, an Android project must be created first, then the Android library module can be created and added.


Video Answer


1 Answers

To import an .aar library:

  1. Go to File>New>New Module
  2. Select "Import .JAR/.AAR Package" and click next.
  3. Enter the path to the .aar file and click finish.
  4. Go to File>Project Structure (Ctrl+Shift+Alt+S).
  5. Under "Modules," in left menu, select "app."
  6. Go to "Dependencies" tab.
  7. Click the green "+" in the upper right corner.
  8. Select "Module Dependency"
  9. Select the new module from the list.
like image 100
Paul Wintz Avatar answered Sep 24 '22 09:09

Paul Wintz