Organize records Androidstudio Package A module project into a jar package.
First, you need to modify the Build.gradld file in the module project you want to package, such as:
Next, add the following code to the Build.gradle file:
task Clearjar (type:delete) {Delete ' libs/sdk.jar '//The SDK is the name of your own jar package, which is literally named} task Makejar (Type:org.gradle.api.tasks.bundling.Jar) {//Specify the generated jar namebaseName ' SDK '//Where to package the class fileFrom (' build/intermediates/classes/debug/org/cmdmac/cloud/pluginsdk/')//directory structure after packaging to jarInto (' org/cmdmac/cloud/pluginsdk/')//Remove directories and files that do not need to be packagedExclude (' test/', ' buildconfig.class', ' R.class')//Remove files starting with Rexclude{it.name.startsWith (' R ');}} Makejar.dependson (Clearjar, build)
Note: These configurations are to be paired with android{...} These configured scripts are in a lateral relationship, never write to android{...} to the.
3, switch to the CMD in Windows, cut to your project path, such as my project path is F:\AndroidStudioProjects\MyApplication\app
Then cut to the path to the directory and enter: Gradle Makejar
as follows:
If prompted: The Gradle command is not available. Then you need to add the variables in your system environment variables:
Where the variable value in Gradle_hom is your gradle path.
Then, at the end of the Path property, add ";%gradle_home%\bin", as follows:
Note: This path must also be edited in the user variable, which I then edited in the system variable, and the dead and Alive configuration was unsuccessful.
After saving, enter gradle-v in your cmd if the configuration is successful, there will be some information about the Gradle version, such as:
Then cut to the path of your project and enter Gradle Makejar:
The following results will appear,
We are prompted to configure the following script in the Bulid.gradle file:
lintoptions {
Abortonerror false
}
Note: This sentence should be written in android{...} configuration inside
Configured SYSN now once the project, run the cmd input again: Gradle Makejar
You will see the following result:
Well, here's the point that our task is complete and we can see the. jar file we named under the Build/libs folder of the project module, as follows:
Android Studio Packs Module into a Jar package