How to create .aar file with library source code?

1.7k views Asked by At

I have a library with all the source files inside of it. I need to compile this library into an .aar file, but I can't seem to import it into a module or project. There is no .idea folder within this library.

How can I create an .aar file out of this?

2

There are 2 answers

0
Chad Bingham On

If the library is in your project with the source, then it is already compiled each time you run. Look under <your_lib> -> build -> outputs -> aar. There you will have an .aar for each build type you have. i.e. debug and release

0
BrentM On

It may be simplest to create a new AAR library module in Android Studio and then copy the source and resources for your library into the new module. To do this select File > New > New Module... > Android Library.

However, if you already have an Android project and you just want to alter the build to generate the project as an AAR library rather than an application, you can change the plugin used in the Gradle build script.

Alter the apply plugin line from:

apply plugin: ‘com.android.application’

to:

apply plugin: ‘com.android.library’