-
打jar包
android studio 默認提供的是aar包,如果要打成jar包的話,就要自己寫gradle task,在庫工程的build.gradle文件中添加一下代碼:
task makeJar(type: Copy) {
delete 'build/libs/mysdk.jar'
from('build/intermediates/bundles/release/')
into('build/libs/')
include('classes.jar')
rename ('classes.jar', 'mysdk.jar')
}
makeJar.dependsOn(build);
然后在終端執(zhí)行命令打出jar包
gradlew makeJar
-
引用aar包
將aar拷貝至lib目錄拱层,在module中的build.gradle文件中添加以下代碼
repositories { flatDir { dirs 'libs' } }
dependencies {
compile(name: 'aar_name', ext: 'aar')
}