-
Notifications
You must be signed in to change notification settings - Fork 56
Creating AAR libraries
AAR is a special Android packaging format that combines code and resources. It
was created to replace the inconvenient library project dependencies that
required you to keep every dependency on your disk in source code format.
Lein-droid used to support it too via :project-dependencies
option, but now
AAR libraries is a preferred method.
How to include already existing AAR libraries is described here, this document focuses on how to create and publish your own AARs.
You can create a library project by executing:
lein new droid awesomelib my.company.awesomelib :library true
This will create a scaffolding for your future library that can contain Java code, Clojure code and resources. In order to build the library use:
lein droid aar
You may also publish the freshly created AAR package to your local Maven repository:
lein droid local-repo
Or you can deploy it to a remote repository just like any other JAR archive. Just make sure that the library is remotely saved as an AAR and not JAR.
If you have a library that you previously used as a project dependency, you can convert it into AAR too. First, execute the following inside its root folder:
lein new droid :init
This will create a project.clj
file for the library. You may want to make
some changes to it, like uncomment :java-only true
if the project only
contains Java code; or provide source paths to Clojure code. To package the
archive you perform the same lein droid aar
.
If the library you are making doesn’t have any resources, you can distribute
it in a JAR like any other Java dependency. In this case you’d want to create
a new library project and remove :packaging "aar".
from project.clj
. To
build the library use:
lein droid jar
Tutorial
- Installation
- Creating a new project
- Quick start
- Libraries and dependencies
- Editors and IDEs
- Troubleshooting
Profiles
Lean compilation
Multi-DEX project
Creating AAR libraries
Hacking the plugin
project.clj options
-
:android
- :aot
- :aot-exclude-ns
- :assets-paths
- :build-tools-version
- :build-type
- :dex-opts
- :external-classes-paths
- :external-res-paths
- :force-dex-optimize
- :ignore-log-priority
- :key-alias
- :keypass
- :keystore-path
- :lean-compile
- :library
- :manifest-options
- :manifest-template-path
- :multi-dex
- :multi-dex-proguard-conf-path
- :native-libraries-paths
- :proguard-execute
- :proguard-conf-path
- :rename-manifest-package
- :repl-device-port
- :repl-local-port
- :res-path
- :resource-jars-paths
- :sdk-path
- :sigalg
- :skummet-skip-vars
- :start-nrepl-server
- :storepass
- :target-version
- :use-debug-keystore
- :dependencies
- :java-only
- :profiles
- *warn-on-reflection*