一.添加jar和aar的方式
在項(xiàng)目中需要添加三方的sdk時(shí)约素,選擇將相關(guān)的jar或aar放入到module中的libs文件夾下后需要在對(duì)應(yīng)的gradle中配置,配置方式有如下兩種:
1.在module目錄下的build.gradle的dependencies中添加
api fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
此種方式簡(jiǎn)單粗暴滥比,但是不允許同時(shí)出現(xiàn)同一個(gè)module不同編譯類(lèi)型的jar(或aar).比如:如果libs同時(shí)存在A-release.aar和A-debug.aar溪北,他們都是來(lái)自同一個(gè)module的打包蜘拉,但是只是編譯類(lèi)型不一樣证膨,如果同時(shí)存在的話如输,會(huì)編譯不過(guò)
2.在module的build.gradle中與dependencies同級(jí)處先添加
repositories {
flatDir
{
dirs 'libs'
}
}
然后在dependencies中添加
implementation(name: '你在libs中添加的arr的名字', ext: 'aar')
或者
implementation(name: '你在libs中添加的jar的名字', ext: 'jar')