我必须在 Android Studio 的子项目中添加 .aar 文件作为库.它给了我一个错误. [英] I have to add .aar files as a library in a sub project in Android studio. It gives me an error.

查看:16
本文介绍了我必须在 Android Studio 的子项目中添加 .aar 文件作为库.它给了我一个错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 .aar 文件添加到子项目的 libs 文件夹中.并已将存储库指定为:

I have added the .aar files to libs folder in the sub-project. And have given the repositories as:

repositories {
 mavenCentral()
    mavenLocal()
    flatDir {
        dirs 'libs'
    } 

在这个子项目的 build.gradle 中.我还需要在 Main 项目的 build.gradle 中添加依赖项吗?如果是,应该怎么做?

in the build.gradle of this sub-project. Do I need to add dependencies in Main project's build.gradle also? If yes, how should that be done?

推荐答案

在你的模块的仓库中:app

In the repositories of your module: app

repositories {

    flatDir {
        dirs 'libs'
    }
}

在你的模块的依赖项中添加以下内容:app如果您同时拥有 JAR 和 AAR 文件,请执行以下操作.

Add the following in the dependencies of your module: app In the case that your have both a JAR and an AAR file, do the following.

dependencies 
{
  implementation (name: '***library name***', ext: 'aar')
  implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'], )

}

这篇关于我必须在 Android Studio 的子项目中添加 .aar 文件作为库.它给了我一个错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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