在Android Studio中导入.aar [英] Importing .aar in android Studio

查看:565
本文介绍了在Android Studio中导入.aar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Android Studio经验不足,我尝试了无数种方法来解决此问题,但均未成功.

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

目标:将.aar文件作为库导入到Android Studio应用中.

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

问题:

  1. 我有一个.aar文件(product_test-debug.aar)
  2. 我使用以下命令将其导入了Android Studio空应用程序:
    • 文件→新模块→导入JAR/AAR包
  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

  1. .aar文件已添加.但是,当我从Android切换到Project模式时,我可以看到该文件仍然显示一个问号.

  1. 忽略问号,在成功完成指南之后,我接下来做了三件事:

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

  • 在settings-gradle中,我将唯一的行修改为:
  • 在build.gradle(Module:app)中,我添加了第一个依赖项:
  • 在此脚本中,我注释了以下行:
  • 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:

所有这些步骤之后,我尝试同步gradle,但它仍然无法识别.aar.这些是错误:

After all these steps, I have tried to sync the gradle and it still does not recognize the .aar. These are the errors:

我试图将.aar文件放入libs文件夹,并将build.gradle(Project:MyApplication)中的此功能更改为:

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:

(顺便说一下,我这样做是为了能够从Android活动中启动示例Unity应用程序.在这种情况下,Unity应用程序是一个旋转的多维数据集.)

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

推荐答案

product_test-debug中build.gradle的第一行应为:

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

apply plugin: 'com.android.library'

并在应用程序的build.gradle中添加:path:

And add :path in build.gradle of app :

compile project(path: ':product_test-debug')

这篇关于在Android Studio中导入.aar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆