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.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Vitor Minhoto
  • 76
  • 1
  • 3

1 Answers1

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')
Dany Pop
  • 3,590
  • 2
  • 21
  • 28
  • 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` – Kuldeep Bhimte Jul 03 '20 at 07:50