Android project combat (thirty-three): get the jar file that depends on the third party, aar to jar under AS

Original: Android project combat (33): Obtaining jar files that depend on three parties, aar to jar under AS

There are several ways to reference third-party code when developing a project using Android studio: jar package, class library, and compile dependencies of gradle.build.

You will find that many projects on github only provide compile dependencies, but what if the jar package is used and the project does not provide a jar package?

In fact, when Android Studio relies on a third-party project in the compile method, it already has the jar package of the project locally. We only need to find the jar package locally.

How to find:

 

1. Under the project outline path: External Libraries, you will find many tripartites used in our current project.

 

2. Select one of them and right-click: select Library Properties... 

 

3. You can see the local path location of the jar package of the tripartite project. You only need to find the jar package in this path.

 

 

Fourth, you can find the jar file in this path.

 Five, resource.jar and jar

In practice, you will find that some three parties can find its resource.jar and jar jar packages, while some three parties can only find resource.jar packages but no jar packages.

Differences between resource.jar files and .jar files:

In fact, the resource.jar package is called a resource jar package, and when we unzip it, we will find that the files in it are all of the .java type. When unzipping the .jar file, you will find that the files are of type .class.

 

And only the jar package with the .class file inside is what we can really use, and the resource.jar resource jar package cannot be used, otherwise a ClassNotFindException will be reported.

 

Then how to obtain the jar package when the three parties found according to the above steps only have the resource.jar package.

Here's another look at the difference between .aar files and .jar files.

* .jar: Only contains class files and manifest files, not resource files, such as pictures and other files in res.

* .aar: Contains all resources, class and res resource files are all included

If you are just a simple class library, you can use the generated *.jar file; if you are a UI library, which contains some self-written control layout files and fonts and other resource files, you can only use *.aar files.

 

According to the above steps 1 --- 4, in fact, we will find 

 

In addition to the .jar file and the .resource.jar file, there is also a .aar file

If there is a .aar file, we can get the .jar file we need from the .aar file 

Proceed as follows:

1. Find an .aar file

2. Modify the file format to .zip About decompression

 

3. Unzip the .zip file 

 

4. The classes.jar is the three-party .jar package we need, just rename it to the name you need.

 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325069094&siteId=291194637