17

I'm trying to build a library and dynamically load it in another app in Android Studio using gradle.

I understand how to create jars and turn them to dex files for loading. But when I build a library in Android Studio with Gradle - I don't get a jar - I get an aar file - which I can't seem to turn to or load as a dex.

How can I turn the aar to a dex file?

shein
  • 1,834
  • 15
  • 23
  • 3
    The objective of having an AAR file -- and an Android library project in general -- is to ship resources along with Java code (whether in source form or compiled). You cannot dynamically add those resources to your other running app, and the code in the AAR would not be able to use them anyway. Hence, do not use an Android library project. – CommonsWare Dec 20 '13 at 18:11
  • aaaa - then if I want to dynamically add functionality to an Android app I should just build it into a jar "the old fashioned way" ? – shein Dec 20 '13 at 18:18
  • 2
    Well, IMHO, you should build your project "the old fashioned way" by compiling in the JARs/AARs ahead of time. IOW, I am not a fan of "create jars and turn them to dex files for loading". That being said, my first comment is merely pointing out that what you're trying to do with an AAR is unlikely to work. If the AAR has no resources, use a JAR instead. If the AAR has resources, you have no real choice but to add it to your app when your app is compiled. – CommonsWare Dec 20 '13 at 18:20
  • 1
    Did you find any way to load dynamically aar library file? – Sai Krishna May 29 '16 at 07:03

1 Answers1

0

You can use dynamic feature delivery and make the AAR part of the dynamic feature module. You can then install the dynamic feature module separately from the core application.

Read more here: https://developer.android.com/guide/playcore/feature-delivery

shubhamgarg1
  • 1,619
  • 1
  • 15
  • 20