在对应的库的build.gradle添加
task deleteJar(type: Delete) {
delete 'libs/mylibrary.jar'
}
task exportjar(type: Copy) {
from('build/intermediates/aar_main_jar/release/')
into('libs/')
include('classes.jar')
rename('classes.jar', 'mylibrary.jar')
}
exportjar.dependsOn(deleteJar, build)
在终端界面输入gradlew exportjar
生成文件路径:libs/mylibrary.jar
导入方法:将生成的mylibrary.jar复制到工程目录下的/libs/,然后在AndroidStudio中右键mylibrary.jar->Add as library
或者在build.gradle中添加
dependencies {
implementation files('libs/mylibrary.jar')
}