The Androidstudio tool exports the module project to the jar and ARR libraries

Source: Internet
Author: User

Original: http://blog.csdn.net/liulei823581722/article/details/52919697

This article first describes how to use Androidstudio to export and convert a module project into a jar, everyone knows that eclipse exports the project jar is very easy, because eclipse is outdated, here is not much to say, follow me to learn more about it!
1, first of all, your module project in the Build.gradld file to modify, as follows:

2. Copy the following code in your Build.gradle file:
Task Clearjar (type:delete) {
Delete ' Libs/sdk.jar '//sdk is the name of your own jar bag, named
}
Task Makejar (Type:org.gradle.api.tasks.bundling.Jar) {
Specify the generated jar name
BaseName ' SDK ' 
//Where to package the class file  
from (' build/intermediates/classes/debug/org/cmdmac/cloud/pluginsdk/')  
//directory structure after packaging to jar  
into (' org/cmdmac/cloud/pluginsdk/')  
//Remove directories and files that do not need to be packaged  
Exclude (' test/', ' buildconfig.class ', ' R.class ')  
//Remove R< Span id= "mathjax-span-2" class= "NoError" to the beginning of the file   
    exclude{  It.name.startsWith (' R ');} &NBSP;
}&NBSP;
MakeJar.dependsOn (Clearjar, build)

Note: These configurations are to be paired with android{...} These configured scripts are in a lateral relationship, never write to android{...} to the.

3, switch to the CMD in Windows, cut to your project path, such as my project path is F:\AndroidStudioProjects\MyApplication\app
Then cut to the path to the directory and enter: Gradle Makejar
as follows:

If prompted: The Gradle command is not available. Then you need to add the variables in your system environment variables:

Where the variable value in Gradle_hom is your gradle path.

Then, at the end of the Path property, add ";%gradle_home%\bin", as follows:

Note: This path must also be edited in the user variable, which I then edited in the system variable, and the dead and Alive configuration was unsuccessful.

After saving, enter gradle-v in your cmd if the configuration is successful, there will be some information about the Gradle version, such as:

Then cut to the path of your project and enter Gradle Makejar:

The following results will appear,

We are prompted to configure the following script in the Bulid.gradle file:
lintoptions {
Abortonerror false
}

Note: This sentence should be written in android{...} configuration inside

Configured SYSN now once the project, run the cmd input again: Gradle Makejar
You will see the following result:

Well, here's the point that our task is complete and we can see the. jar file we named under the Build/libs folder of the project module, as follows:

The Androidstudio tool exports the module project to the jar and ARR libraries

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.