[英]How to convert an .aar file into a .jar
要在IBM MobileFirst Platform项目中使用Eclipse IDE,我需要将.aar文件转换为.jar。 我尝试提取classes.jar文件,但实际上是空的,没有class。 我的意思是,在Android SDK中, extras / android / m2repository / com / android / support / support-v4库仅具有直到24.1版本的类,从那里开始,所有版本都只有空的classes.jar文件。 那么,我该如何处理这些版本中的类?
试图澄清一下这个话题,这个问题对我有帮助:
Android Archive Library(AAR)与标准jar
有人知道将这个Android存档文件转换为Java存档文件的过程吗?
我需要将.aar文件转换为.jar
根据定义,AAR不是JAR,因此不必“转换”为JAR。
通常,如果工件以AAR而不是JAR的形式分发,那是因为工件中不仅有Java代码。
我的意思是,在Android SDK中,extras / android / m2repository / com / android / support / support-v4库仅包含24.1版之前的类
正确。 从那时起, support-v4
一直只是传递依赖项的容器。 您将在工件旁边的POM文件中看到它们的列表。
例如, 25.3.1
POM文件显示了在support-v4
AAR工件的IDE(Android Studio,IntelliJ IDEA等)中使用support-v4
时将拉入的所有工件:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>25.3.1</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-compat</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-media-compat</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-core-utils</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-core-ui</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-fragment</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
从<type>
元素可以看到,大多数传递依赖项本身都是AAR。
有时,AAR除了JAR之外不包含其他内容。 例如, support-core-utils
的25.3.1
版本( support-core-utils
support-v4
25.3.1
的AAR之一)除我所看到的classes.jar
没有其他重要性。
但是,其他AAR的功能超出了JAR。 例如, support-compat
和support-media-compat
具有AIDL文件。 其他AAR(例如appcompat-v7
)具有资源或资产。 如果尝试仅使用AAR中的JAR,并且尝试使用需要这些资源或AIDL文件或任何存在的类,则您的应用程序将崩溃。
您可以尝试将AAR转换为旧式的Eclipse库项目。 俗话说,您的里程可能会有所不同。 另外,我不知道IBM MobileFirst是否支持库项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.