Reputation: 10638
I have built my Android library package (AAR) and the result of build is created in the "..\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 generate the release built, that is, "app-release.aar". How can I do this?
Also, is it possible to generate the build with another custom name, for example, "myCustomAppName-release.aar" instead of "app-release.aar"?
Upvotes: 106
Views: 96604
Reputation: 2863
This issue 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.
Upvotes: 17
Reputation: 2889
In Android Studio 1.2+, there is a context panel listing all available Gradle tasks.
I found this panel on the right side of the IDE with default options enabled.
Right-click the task you want and click "Run".
Upvotes: 124
Reputation: 34205
Create .aar
You can use the 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
The output is located at:
<project_path>/build/outputs/aar/<module_name>-<build_variant>.aar
Alternatively, you can use the Android Studio UI:
Menu View → Tool Windows → Gradle <module_name> → Tasks → Build or others → assembleRelease
Upvotes: 22
Reputation: 1692
From Android Studio v4.x:
Your .aar file will be found in the project file hierarchy on the left, under MyLibrary/Build/outputs
(you may need to first change the view from Android view to Project view, to see these files - using the dropdown at the top left corner).
Upvotes: 13
Reputation: 2243
For me, simply fixing a layout bug in the library that did not produce compile error (missing Android X plugin) fixed it and <lib>-release.aar
appeared alongside the <lib>-debug.aar
in the build/outputs/aar/
folder.
Upvotes: 0
Reputation: 1150
With Android Studio 3.0, it is easier to generate an AAR file. From the Gradle option, check for the option as shown in the picture:
Upvotes: 13
Reputation: 379
Part 1: How can we create a release-only *release.aar
?
Run in Android Studio terminal
(or any terminal in your project folder):
./gradlew assembleRelease
You don’t need signing the configuration for such task.
Part 2: How can we rename the output library to AnotherLibraryName-release.aar
?
Add to your module gradle.build
:
android{
project.archivesBaseName = "AnotherLibraryName"
}
Upvotes: 8
Reputation: 2907
I faced this issue in Android Studio 2.3.3 and solved it by changing the build variant of the module to release and building it again:
Upvotes: 14
Reputation: 5737
Set up your project as an Android library.
In the build.gradle file: plugin: 'com.android.library'
You can see the output in: build/outputs/aar/[your module]
Also see AAR Format.
Upvotes: 3
Reputation: 9142
Add the following script to your android{} tag in file build.gradle to generate a release build:
signingConfigs {
testConfig{
storeFile file("X:/XXXX/yourkeystore")
storePassword "yourKeyPassword"
keyAlias "yourAlias"
keyPassword "yourAliasPassword"
}
}
buildTypes{
release {
signingConfig signingConfigs.testConfig
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Run command "gradle clean build" in your command line.
Upvotes: 7