This question is so basic, and I didn't find documentation for it.
I have an Android Library project, and I would like to export an aar file of it, and use it in another project.
I have the following gradle.build file, from so many other examples:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 7
}
}
I would like to use pure Gradle to run this, which means that I need to run the tasks, but first things first, I get the following error:
> Plugin with id 'android-library' not found.
Why does the plugin not found, and which tasks should I run?
Thanks, Adam.
The difference between JAR and AARJAR is just a Java library containing java class files and nothing more. AAR is a format for android libraries which contains a JAR file, android resource file (like layout XML, attribute XML, etc..) and an android manifest file.
It will show up in the build/outputs/aar/ directory in your module's directory. You can choose the "Android Library" type in File > New Module to create a new Android Library. If you are still not seeing your aar file, select Build > Rebuild Project .
AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods. AAR files can contain C/C++ libraries for use by the app module's C/C++ code.
Here's what has worked for me. It's manual, but it is a pure gradle way to do it. This assumes that you have 'apply plugin: "android-library" in your module's build.gradle file which I see you have.
on the command line go to the root directory of the project
ensure that your JAVA_HOME environment variable points to the version of the java sdk you are going to use. On a Mac via the bash shell that would look something like this:
export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home'
(click here to find out how to find your Java Home)
You should now find the .aar file in mymodulename/build/outputs/aar
Thanks to [geekgarage] for clarification.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With