Android Library and Proguard
2018-01-11
Tech
367
Android Library
To build a android library project, simply change the following line in build.gradle (Module):
apply plugin: 'com.android.application'
to:
apply plugin: 'com.android.library'
To pack the library into a jar file, add these lines to build.gradle (Module):
def JarLibName="YourLibName"
task clearJar(type: Delete) {
delete 'build/generated/' + JarLibName + '.jar'
}
task makeJar(type: Jar) {
from zipTree(file('build/intermediates/bundles/release/classes.jar'))
baseName = JarLibName
destinationDir = file("build/generated")
}
makeJar.dependsOn(clearJar, build)
And run the following command in the Terminal:
./gradlew makeJar
If failed in lint process, add these to build.gradle (Module):
android {
// ...
lintOptions {
abortOnError false
}
// ...
}
Remember to copy the jar library file