许多像support-v4这样的Android库都是以支持-v4-19.1.0.jar作为jar文件提供的,但后来它们可以作为aar文件使用,例如support-v4-25.1.0.aar。因此,jar文件可以直接使用javac引用:
javac -classpath library.jar -sourcepath java -d bin java\com\example\*.javalibrary.aar也可以直接与javac集成吗?或者说最好的方法是什么?
发布于 2020-02-20 18:24:43
AAR文件是Google用于Android的专用文件。然而,javac是一个独立于Android和Google的编译器。因此,使用javac目前无法访问aar容器中的组件。
唯一的方法是解压缩aar文件,然后使用所需的组件。问题中提到的组件对应于aar文件中的classes.jar。例如,在windows上可以将aar文件与javac一起使用,如下所示:
rem define a system zip unpacker
set UNZIP="C:\Program Files (x86)\System\7-Zip\7z.exe" x -o
rem unzip the aar file
%UNZIP%C:\programming\extras\android\libs\unpacked\support-v4-25.1.0 ^
C:\programming\extras\android\m2repository\com\android\support\support-v7\25.1.0\support-v4-25.1.0.aar
rem use the extracted classes.jar library
javac -classpath C:\programming\extras\android\libs\unpacked\support-v4-25.1.0\classes.jar -sourcepath java -d bin java\com\example\*.java https://stackoverflow.com/questions/60269467
复制相似问题