我知道这个问题:添加本地 .aar 文件到我的 gradle 构建,但该解决方案对我不起作用.
我尝试将此语句添加到我的 build.gradle
文件的顶层:
存储库{mavenCentral()平面目录 {目录'库'}}
我还将 slidingmenu.aar
文件放入 /libs
并在 dependencies
部分中引用它: compile 'com.slidingmenu.lib:slidingmenu:1.0.0@aar'
但它根本不起作用.
我也尝试过compile files('libs/slidingmenu.aar')
,但没有成功.
我错过了什么?有什么想法吗?
附:Android Studio 0.8.2
以 Josiah 的回答为基础,这就是我如何让它发挥作用的方法.
按照他的指示(正在编辑)(文件 -> 新建 -> 新模块 -> 导入 .JAR/.AAR)并导入您的 .AAR.
然后在你的项目 build.gradle(不是顶层,'app'下的那个)添加以下内容(在依赖项部分):
依赖项{编译项目(':Name-Of-Your-Project')}
注意 Name-Of-Your-Project 应与导入 AAR 文件后添加的文件夹的名称相匹配(与最顶层文件夹下的 app/.idea
处于同一级别).或者换一种说法……
这对我运行 Android Studio 0.8.0 很有用.完成此操作后不要忘记同步 gradle(使用工具栏按钮或在 File->Synchronize 中).
(感谢 Josiah 让我朝着正确的方向前进)
(注意:在此之前我尝试将其添加到 libs 文件夹中,尝试操作顶级 build.gradle
和应用程序级别 build.gradle
,但是这些都不适用于我的 aars 文件——jar 可以正常工作,但 aar 文件不行)
I'm aware of this question: Adding local .aar files to my gradle build but the solution does not work for me.
I tried adding this statement to the top level of my build.gradle
file:
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
I've also put the slidingmenu.aar
file into /libs
and referenced it in the dependencies
section: compile 'com.slidingmenu.lib:slidingmenu:1.0.0@aar'
but it did not work at all.
I tried compile files('libs/slidingmenu.aar')
as well but with no luck.
What am I missing? Any ideas?
P.S. Android Studio 0.8.2
Building upon Josiah's answer, here's how I got it to work.
Following his instructions (under edit) (File -> New-> New Module -> Import .JAR/.AAR) and import your .AAR.
Then in your project build.gradle (not the top level one, the one under 'app') add the following (in the dependencies section):
dependencies {
compile project(':Name-Of-Your-Project')
}
Note Name-Of-Your-Project should match the name of the folder that was added after you imported the AAR file (at the same level as app/.idea
under the top most level folder). Or to put it another way...
MyApplication .idea app build.gradle (here's where to add compile project(':ProjectName') to dependency section) ProjectName (added automatically after importing, matching the name of your aar file) build gradle etc
This worked for me running Android Studio 0.8.0. Don't forget to synchronize gradle (using toolbar button or in File->Synchronize) after you do this.
(Thanks to Josiah for getting me going in the right direction)
(Note: prior to this I tried adding it to the libs folder, trying to manipulate the top level build.gradle
and the app level build.gradle
, but none of that worked for my aars files--jar's will work fine, but not the aar files)
这篇关于使用“flatDirs"将本地 .aar 文件添加到 Gradle 构建中不管用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!