只需将aar包放入libs即可
repositories {
flatDir {
dirs 'libs'
}
}
//subdir 对应不同的环境
def listLocalAAR={dir,subdir->
def aars=[];
fileTree(dir).include("*.aar").each{
aar->aars.push(':'+aar.name.replaceFirst('\\.aar$','@aar'))
}
fileTree(dir).include("$subdir/*.aar").each{
File aar->aars.push(':'+subdir+'/'+aar.name.replaceFirst('\\.aar$','@aar'))
}
println subdir+':'+aars
return aars
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(listLocalAAR('libs',''))
}
如果不想区分环境
写成以下也行
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.aar'])
}