1. File->new Moudle-Android Library
This creates a library project, opens his Build.gradle project.
Apply plugin: ' Com.android.library '
Android {
Compilesdkversion 23
Buildtoolsversion "23.0.3"
Defaultconfig {
Minsdkversion 16
Targetsdkversion 23
Versioncode 1
Versionname "1.0"
}
Buildtypes {
Release {
Minifyenabled false
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
}
}
}
dependencies {
Compile Filetree (dir: ' Libs ', include: [' *.jar '])
Testcompile ' junit:junit:4.12 '
Compile ' com.android.support:appcompat-v7:23.4.0 '
}
============== The following is what you want to add ======================
the task to delete this old jar indicates that an older version of the *.jar name under this directory will be deleted
Task Deleteoldjar (type:delete) {
Delete ' Release/androidplugin.jar '
}
The task to export contents as jar copies files from the FROM (*) directory under release/and changes the name to Bsdiff.jar
Task Exportjar (type:copy) {
From (' build/intermediates/bundles/release/')
Into (' release/')
Include (' Classes.jar ')
Rename the jar
Rename (' Classes.jar ', ' Bsdiff.jar ')
}
Exportjar.dependson (Deleteoldjar, build)
This sets the files you want to pack into the Src/main/java directory later on
Click Exportjar to find your packaged jar package in the Library/release/*.jar you created.
Android Studio packages files into jar files