6

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.

Problem:

  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.

a

  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.

b

c

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

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

g

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

h

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:

https://medium.com/@ericdejesus/im-getting-this-error-whenever-i-try-to-build-to-project-from-unity-any-idea-how-to-solve-78d5c22a4571

(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.

2
  • Did you declare product_test-debug as a module in gradle ? Commented Nov 30, 2017 at 23:55
  • This answer works for me: stackoverflow.com/a/21450829/4409409 Commented Dec 1, 2017 at 1:01

1 Answer 1

0

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

apply plugin: 'com.android.library' 

And add :path in build.gradle of app :

compile project(path: ':product_test-debug') 
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Dany, I am trying to achieve the same thing. I can import it successfully. But I am not able to use it. When I use the class it says cannot find symbol

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.