生成arr包
Module 配置為 library,在 gradle 文件中如下:
輸出 aar : apply plugin: ‘com.android.library’; 在moudule的build->utputs->aar目錄下就能找到生成的arr文件
其它項目引入
Gradle 的一些基本依賴配置方式如下:
compile fileTree(dir: ‘xxx’, include: [‘.jar’, “.xxx”]): 將某個目錄下 所有符合擴展名的文件作為依賴;
compile ‘com.xx.xx:ProjectName:Version’: 配置Maven` 庫作為依賴;在 Maven 庫中心 可以搜索自己想用的庫進行依賴;
compile project(‘:AnotherModule’): 配置另一個 Module 作為本 Module 的依賴,被依賴的 Module 必須被導入到當前工程中;
compile files(‘xxx.jar’): 配置某個 jar 包作為依賴。
這里寫圖片描述
導入后再在依賴中添加該module
方法2: 將arr放入libs目錄下 在app module build.gradle 添加
repositories {
flatDir {
dirs 'libs'
}
}
compile(name: 'facebook-android-sdk-4.11.0', ext: 'aar')
compile 沒有擴展名的 且記 和導入jar包的區別,導入jar包是有擴展名的
引入成功可在build->intermediates->exploded-arr文件夾下看到
這里寫圖片描述
其它參考 http://www.androidchina.net/2467.html