How to use an android library (.aar file) in Ionic with Capacitor


I need to use a library from an android device, that was passed to me in an aar file, in a project with Ionic and I can’t integrate it. Searching all I find is that it should make a Cordova plugin but I am using Capacitor.

I need to be able to integrate it into the project and use it with typescript.


If someone has the same problem, what I did was create a Capacitor plugin using the command npm init @capacitor/plugin.

The issue was that there was an error when including the .aar library within the plugin, as it compiles as an .aar library on its own.

You have to place the .aar library inside /android/libs of both the plugin and the project, and in the plugin’s build.gradle file, add it as compileOnly files('libs/[lib_name].aar') instead of an implementation.

Answered By – estebanovic

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published