廢話不多說,直接上例子。
這裡以添加rxandroid 這個aar為例說明android studio添加aar的步驟。
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiN2UDOxAzM2EDNyATM2EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)
在上圖的build.gradle中添加以下代碼
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile (name:'rxandroid-1.2.0',ext:'aar')//你需要修改的是檔案的名字也就是'rxandroid-1.2.0'這一部分
}
repositories {
flatDir {
dirs 'libs'
}
}
然後點選同步就可以了。
驗證添加是否正确?
android studio aar 添加依賴
在這個目錄下找到你添加的檔案就好了。
就這麼多了,這是一種辦法,還有用model的方式添加的,沒這個友善就不寫了。