If you have a project that includes JAR files and AAR files as dependencies (see note below), then you can use Android JARs as dependencies that depend on classes in the Android API, although JAR files cannot contain Android Resources , As you already know. Just because it depends on the classes of Android, it does not mean that it should be packaged as AAR.
Here I am talking about that, perhaps, a single-module project that includes a number of JAR and AAR dependencies. A JAR file is just a collection of class files (and possibly non-Android resources and other files) and does not make sense of dependencies, so nothing is broken. When the time comes for assembly, the builder simply bundles everything together and packs it and does not check if the JAR has unsolvable dependencies on other classes - you will find exceptions with loading classes at runtime.
If you are talking about the modules library in a multi-module project in the IDE, then this is another matter. If you have module A that can compile a simple JAR (it uses the apply plugin: 'java' statement in the assembly file), then it cannot depend on the Android module ( apply plugin: 'android-library' ) that compiles into AAR . This will probably never be fixed, or at least not in the foreseeable future: since the Android modules have a much more complicated idea of ββthe source folders, and the Java plugin in Gradle cannot understand the original Android settings.
The converse is true, though - Android modules may depend on simple Java modules.
Note
Due to limitations not yet allowed in the Gradle builder, you cannot access local AARs in the same way as JARs in build files (by referencing them using compile files(...) operators); you should fool Gradle into thinking that they are in some Maven repository (perhaps putting them in the Maven repository is the actual one , which may be local). See Adding local .aar files to my Gradle construct for a workaround if you need to.
Scott barta
source share