Detailed steps for Android studio to generate custom jar packages

If you want to export a project as a jar package for use by other projects, you can directly export the project as a jar package in eclipse, and you can modify gradle in as.

Next, we will introduce the following specific steps:

1. Create a new project with any name, eg: makejarapplication. Create a new module in the project, with the type of Android library and the name of testlibrary. As shown in the figure:

Project structure diagram

2. Let app rely on this library, and add compile project (': testlibrary') in the build.gradle file under app

3. Create a testshow class in testlibrary so that external apps can call it. And call it in app.

(1)TestShow .java

(2)、MainActivity.java

4. The configuration in build.gradle of testlibrary can generate jar files:

Including SDK_ BASENAME = "TestSdk"; SDK_ VERSION = "_V1.0"; Yes, the name of the generated jar is defined as testsdk_ V1.0.jar。

5. There is "other" in the gradle directory on the right. Expand to find "makejar", and then double-click "makejar" to generate jar files. The generation results are as follows:

Step result map

Now you can copy testsdk.jar to the LIBS directory in a new module, and then call new testshow(). Show (context, "", show_tv); There's no way.

6. Call the result in the project:

summary

The above is a detailed explanation of the steps for Android studio to generate custom jar packages introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message and Xiaobian will reply to you in time!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>