Android Studio : AAR Library dependency inside another AAR Library - android

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

Related

Building aar library from multimodule project

I've got a multi-module Android project which have one module called app which is the Android application, that contains features where each feature is separate module.
I would like to extract one of the feature modules as a aar library.
I started from creating a demo app inside the project that have my feature module as a dependency:
implementation project(':player')
I adjusted the code of the app to make it working and in my Demo app inside the project it was working as expected.
My next step was to build the aar file and include it in separate project. I did it by using task:
Gradle -> player -> Tasks -> build -> build
After importing created aar file in new project I'm getting a lot of java.lang.ClassNotFoundException exceptions because classes from modules that player module depends on are not in the generated .jar file.
I didn't mention, but player module depends on few other modules like domain, base-android, data and so on and it seems like all of those modules are not included in aar file.
At first I thought that changing from implementation for those modules to api will solve the problem, but it didn't.
My question is: is there something I'm missing while building the aar library? I thought that if something is working great when included in the module within one project then it should also work like that when after creating a aar file, but it seems like it's not.
You are getting ClassNotFoundException as your module's aar doesn't contains your other submodules' code or aar files. To fix this issue you can check out this gradle plugin that will include all sub modules's arr into your main module automatically. Check out fat AAR, here is the link : https://github.com/kezong/fat-aar-android

How to use java dependencies to xamarin android project?

I have an gradle dependencies:
dependencies {
implementation 'com.github.ekodevelops:eko-gateway-android-sdk:1.2.0'
}
Want to create a *.aar file and use it my Xamarin android project
How to do it?
We could use the following steps to create a Bindings Library from the .AAR file:
Create a new Java Bindings Library project.
Add a single .AAR file to the project. A binding project may only
contain a single .AAR.
Set the appropriate build action for the .AAR file.
Choose a target framework that the .AAR supports.
Build the Bindings Library.
then we could add a reference to the Bindings Library in your Xamarin.android project.
for details, please refer to Binding an .AAR

Add .jar dependency to Java Library Module Android Studio

I am trying to create a Java library in Android Studio. I want to use functionality of another Java library (third party available as a .jar) in it. So I placed the library in libs folder of my java library project and added the following code in build.gradle file:
apply plugin: 'java-library'
dependencies {
implementation files('libs/libraryname.jar')
}
The .jar reference was added successfully and I can use the library methods in my code. My project also compiles successfully and I am able to generate a .jar file of my own java library project.
However, when I am using the generated .jar file in another project and try to access the methods of third party library, I get the following exception:
java.lang.ClassNotFoundException: Didn't find class
"com.packagename.classname" on path: DexPathList[[zip file
"/data/app/com.packagename-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64,
/system/lib64]]
What I have tried
I have tried multiple solutions provided here and here but none of them works.
I have tried to clean and re-build the project and .jar files as well but that doesn't help as well.
I have added the .jar dependency as a module before referring it in my project but it still generates the same error.
Note:
I am using Android Studio 3.1.4
Copy .jar in your libs project folder: change the navigator to project view, than you are able to see libs directory.
Right click on your jar folder inside your project and select add as library, this will automatically import the library on your gradle dependencies

How to create an inclusive aar file in Android

How do we create an aar file that includes all its dependent projects in Android gradle build?
Say I have ProjectA that is Android gradle library that depends on another library called ProjectB which is in ant build. I would like to build an aar file thats inclusive of 'ProjectB`.
If its not possible across two different build systems.

Avoid code duplication in Android Studio modules

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

Categories

Resources