Reputation: 355
I want to build android library as AAR file that includes dependencies in output AAR file. It uses another AAR file as dependency from libs folder.
Building library shows this error:
Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR.
I tried extracting AAR file as module
And then imported it as a project
Build command worked, but it does not include external library in classes.jar
My proguard-rules.pro file is
-dontwarn javax.annotation.Nullable
-dontwarn com.facetec.sdk.**
-keep class com.facetec.sdk.** { *; }
I've also tried to use https://github.com/kezong/fat-aar-android library and imported facetec-sdk module as embed project, but build command showed lint error
Upvotes: 5
Views: 12134
Reputation: 15
try to put into dependences in build.gradle:app file this string:
api fileTree(dir: 'libs', include: ['*.aar'])
Upvotes: 1
Reputation: 123
I had a similar issue whilst trying to create an android library with a dependency on a SDK that was delivered to me in .aar format. With the newer AGP (Android Gradle Plugin) 4+, not allowing to compile the aar within the android library I was creating - showing me this error: "Direct local .aar file dependencies for a library module are not supported when creating an AAR for the library module.."
I was able to find this link https://www.programmersought.com/article/63808911660/ with an answer that helped deeply, and which gave me the solution to also compile the aar, and also allow me to import it's classes inside my android library.
cutting short -
flatDir {
dirs 'libs' //this way we can find the .aar file in libs folder
}
api(name: '/name/', ext: 'aar')
It currently works, and I hope there is no issues with it later on, but AS is giving a warning to avoid using flatDirs. but Ive wasted too much time on this issue, If anyone has more insight I'll be happy to receive any.
Upvotes: 3