As package jar and AAR

Time:2021-11-28
  • Jar packaging (only class files and manifest files are included, not resource files, such as pictures and all files in Res)

1. Create a new project in as and a new model module. Add the model dependency to build. Gradle in the project, and then compile the project. Then add the following configuration in build.gradle of the module:

task makeJar(dependsOn:['compileReleaseJavaWithJavac'], type: Jar) {
    Delete 'build / LIBS / hssdk. Jar' // delete
    Archivename 'hssdk. Jar' // specify the generated jar name
    From ('build / intermediates / javac / release / compilereleasejavawithjavac / classes') // where to package the class file
    from (project.zipTree('libs/common-1.5.20.jar'))
    destinationDir = file('build/libs')
    //Remove directories and files that do not need to be packaged
    exclude('com.shgbit.hssdk/BuildConfig.class')
    exclude('com.shgbit.hssdk/BuildConfig$*.class')
    exclude('**/R.class')
    exclude('**/R$*.class')
    include('**/*.class')
}

2. Click gradle – corresponding module – tasks – other – makejar on the toolbar on the right side of the project to complete it

As package jar and AAR

  • AAR packaging (including all resources, class and res resource files)

1. Create a new project in as and a new model module. Add the model dependency to build. Gradle in the project, and then compile the project.

2. Click build make module in turn to produce AAR in the build outputs AAR folder of the module

As package jar and AAR