Android Studio packages files into jar files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.