How to create a release android library package (aar) in Android Studio (not debug)
Solution 1
In Android Studio 1.2+, there is a complete gradle
menu that lists all of the available gradle
tasks.
I found this menu on the right side of the IDE with default options enabled.
Right click the task you want and click "Run".
Solution 2
This issue of can already be handled with the answers like execute
./gradlew assembleRelease
or choose assembleRelease from Android Studio's Gradle menu. However, for completeness, with Android Studio 1.5.1 (and probably also older versions) building release version of a .aar can be accomplished by selecting Build->Build APK in Android Studio. It seems to execute assembleRelease. If your project only contains the library project, it does not ask for any signing information.
Solution 3
With Android Studio 3.0 is easier to generate aar file. From the Gradle option, chek for the option as shown in the picture
Solution 4
I faced this issue in AS 2.3.3 and solved it by changing the build variant of the module to release and building it again:
Solution 5
Create .aar
You can use command line
./gradlew <moduleName>:assemble
./gradlew <moduleName>:assemble<build_variant>
//for example
./gradlew <moduleName>:assembleRelease
//or
./gradlew <moduleName>:bundle<build_variant>Aar
//for example
./gradlew <moduleName>:bundleReleaseAar
//output is located
<project_path>/build/outputs/aar/<module_name>-<build_variant>.aar
Alternatively you can use AndroidStudio UI
View -> Tool Windows -> Gradle
<module_name> -> Tasks -> build or others -> assembleRelease
Comments
-
Rodri over 2 years
I have built my android library package (aar) and the result of build is created in "..\app\build\outputs\aar" folder. The file within this folder is called "app-debug.aar" so I guess it has been built in debug mode so I would like to know how to genereate the release built, that is, "app-release.aar". How can I do this? Also, is it possible to genereate the build with another custom name, for example, "myCustomAppName-release.aar" instead of "app-release.aar".