[英]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.