How to Create a Release Android Library Package (Aar) in Android Studio (Not Debug)

Android Studio release build does not output aar

To get the aar, you can do the following

1) “View/Tool Windows/Gradle”, to open the gradle window

2) From gradle window, run assembly Gradle task by double-click on My_Plugin_Android/:My_Plugin/Tasks/build/assemble

Then the release and debug aars are outputed.

How to create new Android AAR in Android Studio

After days of unsuccessful head-banging with the IDE, I found an astoundingly simple solution in some Google results, namely:

  1. Manually edit project/app/build.gradle
  2. Change apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
  3. Remove the line specifying applicationId.
  4. Build->Clean Project and Build->Rebuild Project.

Voila! New library app-debug.aar appears in project/app/build/outputs/aar/

I don't know where the name app-debug came from, but you can rename it afterwards if you like.

UPDATE 7/2/18

I omitted precursor steps to this procedure. They are

1. Create a base project however you normally do.

2. Delete classes and other stuff you don't need in the aar.

3. Follow the steps above.

Why won't Android Studio create my AAR file in release mode

Right click the task you want and click "Run".

Sample Image



Related Topics



Leave a reply



Submit