Importing .aar in android Studio [duplicate]

December 01, 2017, at 1:47 PM

This question already has an answer here:

  • How to manually include external aar package using new Gradle Android Build System 14 answers

I am not very experienced in Android Studio and I have tried countless ways to solve this issue with no success.

Goal: Import an .aar file as a library into an Android Studio app.


  1. I have a .aar file (product_test-debug.aar)
  2. I imported it into an Android Studio empty app, using:
    • File → New Module → Import JAR/AAR Package
  3. I already had one issue in this phase, perhaps due to the question mark in the .aar file; after selecting the file, Android Studio studio would tell me it didnt exist. This error mysteriously disapeared so I'll carry on.

  1. The .aar file was added. However, when I switch from Android to Project mode, I can see the file still shows a question mark.

  1. Ignoring the question mark, I did 3 things next, following a successful guide:

    • In the settings-gradle, I modified the only line to:
    • In the build.gradle (Module:app), I added the first dependency:
    • Still in this script, I commented the following line:
  2. After all these steps, I have tried to sync the gradle and it still does not recognize the .aar. These are the errors:

I tried to put the .aar file into the libs folder, and alter this function in build.gradle(Project:MyApplication) to this:

But it doesn't solve anything. I know what I am trying to do is possible because of the guide, but I don't know what I am missing. The guide is this one for reference:

(Btw for context, I am doing this to be able to launch a sample Unity app from an Android activity. In this case, the Unity app is a spinning cube.)

Thank you very much for your time and assistance in this matter.

Answer 1

The first line of build.gradle in product_test-debug should be :

apply plugin: ''

And add :path in build.gradle of app :

compile project(path: ':product_test-debug')
How to link from source code to selective header file path in

How to link from source code to selective header file path in

I'm stuck on an issue on an Android App, that needs to selectively pick a header file from directory defined in Androidmk

Beginner game development using java guidance [on hold]

Beginner game development using java guidance [on hold]

As stated, I have studied the basics of Java and I want to get into game development using JavaThat being said, I understand I should start small

Android Nested Data Modeling

Android Nested Data Modeling

I have the following contract

How to get fragment from inflated layout

How to get fragment from inflated layout

I have inflated layout content_mainxml to view variable vi