Android Studio how to package a JAR package, androidjar

Source: Internet
Author: User

Android Studio how to package a JAR package, androidjar

How to package a JAR package in Android Studio

In eclipse, we know how to export a project as a jar package for other projects.
In AS, you can modify gradle for processing.
Create a new project MakeJar and create a new modle in the project. The modle type is library.

The app is our main project, and librarydemo is the model for generating the jar package.
Add the following code to librarydemo:

Task makeJar (type: Copy) {delete 'build/libs/mysdk. jar 'from ('build/intermediates/bundles/release/') into ('build/libs/') include ('classes. jar ') rename ('classes. jar ', 'mysdk. jar ')} makeJar. dependsOn (build) // execute the JAR package generated on the terminal // gradlew makeJar

In Terminal, type gradlew makeJar and press Enter. You can see the following:

Of course, you must add the librarydemo dependency model to the build of the main project App:

Dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) compile 'com. android. support: appcompat-v7: 22.2.0 'compile project (': librarydemo ')}

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.