I know there was an issue in the past with Eclipse ADT where you could not compile a library project to a JAR if it contained resources.
Is it possible to do this with Android Studio and compile to an AAR file? I would also like to convert the AAR file to JAR and need to know if this will cause issue.
Thanks
With the Android Gradle Plugin, you can package a library as aar or, if your library doesn't contain Android resources, as a jar using this method.
Related
I am using Android studio 1.5. I have a library project, core-speech-service.aar. This AAR file is generated correctly (all classes are built and packed inside classes.jar in the AAR file).
Now I am creating another AAR library google-speech-service.aar which depends on the first AAR (core-speech-service). So I add it as library dependency (compile) in the new AAR library project.
So far, so good. Android studio copies core-speech-service.aar in to the new library project as a library module. But when I build the google-speech-service library project, it creates an AAR file, but the packed AAR file neither contains classes from the core-speech-service.aar neither it has the core-speech-service.aar itself.
Am I missing something ?
Thanks
abhay
You will have to reference the library as an outside dependency on your apk. I believe that as of now you cannot have an aar inside another
I've created a project and a library separately using Android Studio, each in a separate folder inside some directory.
I tried to add the library as a module to the project, and noticed that instead of just referencing the library like in Eclipse, the library was copied inside the project directory.
That means that if this happened N times for N projects, then I'll have N copies of the library and I'll need to update them all when any update is to be done.
I'm working on v 1.0.2 of Android Studio.
Any one has a better idea to do it?
Three options I know of:
You can specify the path to the external library:
Android studio add external project to build.gradle
Include the compiled jar file from the library in the libs directory of the N apps.
Publish the artifact (the jar from library project) to a gradle repository and then you can add dependencies to that project just like you would for the support library etc.
See http://gradle.org/docs/current/userguide/artifact_management.html
I'm working on a library project that provides access to a service. We started the project few months ago and we were supporting Eclipse only (since Android Studio was a prewview edition).
Now that Android Studio has become a "beta" version, and its popularity has increased greatly, we had the intention to support it as welll, but we are facing the problem of how to support both "styles" with the same base (project structure and code).
The library we are building has a UI that forced us to have the library as library project instead of just a simple jar. We have this project working with ANT to build the required files (jars) and packaging everthing in a library project.
Android Studio now introduces the .aar library files, that can also contain UI.
So our problem is finding examples of other library projects containing UI that are also supporting both IDE's. Wondering if someone else have face this same situation.
Is is possible to have a Library Project to support both IDEs? (Eclipse and Android Studio)
Thanks to #CommonsWare. When I looked at your projects I realize that we didn't need our project to be "Android Studio compatible". Since we wanted to share the project as an .aar file, I had only to make a build.gradle at the root of my library project and add the gradle folder (containing the gradle wrapper jars).
In this way I can use the console and create a .aar file using "./gradlew aR" command. Now I can distribute the library project for Eclipse users or the .aar file for Android Studio users.
I'm testing the .aar file, and the only problem I have right now is that classes inside a jar file within libs folder inside the .aar file are not recognized, just the classes present inside "classes.jar", but I think I would create another question here in SOF since is not relevant for this question.
How do I build a JAR file from an Android Studio project? I've followed a lot of guides without much success. I tried compiling as a regular and library project but no JAR file get automatically generated. Do I have to do it manually or resort to Ant to get the Jar file?
Android Studio will compile your library into an AAR not a JAR. AARs are a little different since we rely on the SDK rather than a JAR to give use the Android API.
You will find the AAR under LibraryName/build/libs/LibraryName.aar.
I've seen lots of libraries in github that has no dependencies for adding them to a project.
The questions are:
How can I use these libraries?
How can I add them to my project?
For instance, this is a gitbub project that I don't know how to use those:
https://github.com/zzhouj/Android-SlidingUpPanel
Normally, you would download a JAR file - if any - or download the project and build the JAR yourself (like you would do for Volley project). But if there is no JAR support, like Android-SlidingUpPanel, just download it and add it as a module in your project.
Try doing this way;
download android-support-v4.jar, add to your LIBS folder,
build project.