問題描述
我知道這個問題:添加本地 .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模板網!