0

Many Android libraries like support-v4 was provided as jar file with support-v4-19.1.0.jar, but later they are available as aar file e.g. support-v4-25.1.0.aar. So, jar files can be referenced directly with javac:

javac -classpath library.jar -sourcepath java -d bin java\com\example\*.java

Can also a library.aar be integrated directly with javac? Or what's the best way?

gotwo
  • 663
  • 8
  • 16
  • You should explain why, as AAR files just package Android specific libraries & related resources. – Morrison Chang Feb 17 '20 at 20:00
  • 1
    The library will be useless without the resources; so converting it is pointless. [How to convert AAR to JAR](https://stackoverflow.com/questions/21417419/how-to-convert-aar-to-jar). – Martin Zeitler Feb 17 '20 at 20:57

1 Answers1

0

AAR files are specific used by Google for Android. However, javac is a compiler independent of Android and Google. Therefore, with javac is currently no way to access components within the aar container.

The only way is to unpack the aar file and afterwards to use the needed components. The component mentioned in the question corresponds to the classes.jar inside the aar file. For example, the aar files can be used with javac on windows cmd as follows:

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 
gotwo
  • 663
  • 8
  • 16