Android Studio Export Jar Package

Source: Internet
Author: User


Moudle for the library type in Android studio, so to export the jar package, we first need to put the code we want to export into a moudle.

1. Under current engineering, File--new--new Module

2. Add the function code to be exported in the module

3. Introduce the module in the app

Add the dependency of this module to the app's Build.gradle, as follows:

dependencies {compile ' com.android.support:appcompat-v7:21.0.3 ' Compile project (': MyLibrary ')}

4. Compile the project and you can see that the jar package has been generated in the path.

./mylibrary/build/intermediates/bundles/debug/classes . Jar

./mylibrary/build/intermediates/bundles/release/classes . Jar

5. Manually change the Classes.jar to the desired name, and the other functions can be used to import the jar package.


6. You can also change the 5th step to a jar package that automatically generates the required names by adding a task to the Build.gradle in Moudle:

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) then execute the build jar package at the terminal./gradlew Makejar this way, you can see the jar package in the module's Libs directory.

Btw

If you want to remove the module, you must first "subtract" the module in File->project structure to be available in the project by the DELETE key of the module's right-click.



This article is from the "whatever957" blog, make sure to keep this source http://whatever957.blog.51cto.com/6835003/1791548

Android Studio Export 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.