Android Studio to play module into jar package

Source: Internet
Author: User

1. New test project, two Module,app is Android project, MyLibrary is the Android library.

2. Open the Build.gradle file in the MyLibrary directory and add the following code block.

task Makejar (type:copy) {Delete'Build/libs/mylibrary.jar' //Delete a jar package that already exists     from('build/intermediates/bundles/release/')//load the files to be packaged from this directoryInto'build/libs/')//Save directory for jar packagesInclude'Classes.jar')//set filters, package only classes filesRename'Classes.jar','Mylibrary.jar')//Rename , Mylibrary.jar set according to your own needs}makejar.dependson (build)

3. Enter the Gradlew Makejar command in the as Terminal window.

4. Run the above command (the first time will automatically download the required dependencies, a little longer), the result is as follows, packaging is successful.

5. Copy the generated jar package for use by other projects

If the following error occurs when you run the Gradlew makejar command (MyLibrary is the name of my library):

 for ' : Mylibrary:lint ' .  in the project; Aborting build.

In the Build.gradle file under the MyLibrary directory, add the following code block (note where the code block is located), and re-execute the gradlew makejar command:

lintoptions {       false   }

Android Studio to play module into jar package

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.