Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android load modules dynamically

I wanna write an android application which can be extended with modules (android libraries). The modules shall be loaded at runtime. Therefore they'll be downloaded from an url and stored in a directory. The modules are aar files.

Is there a way to load aar files dynamically at runtime?

I know it's possible to just load the contained classes.jar with an URLClassLoader. But than I can't load the layout, string, ... resources. HM

Does anyone know a way how to solve this?

EDIT:

I found a few related topics:

  • Dynamically loading aar library
  • https://stackoverflow.com/questions/25919338/is-possible-to-include-a-dynamically-aar-file
  • Write Plugin for Android App
  • Plugins architecture for an Android app?
  • How to develop an app that has add-ons?
  • Android - Build an application that supports add-ons

It seems that it doesn't work because of the answer from the first link. I hope I'm wrong with that thinking.

like image 200
boeserwolf91 Avatar asked Nov 03 '14 10:11

boeserwolf91


People also ask

What is dynamic module in Android?

Dynamic feature modules allow you to separate certain features and resources from the base module of your app and include them in your app bundle. Through Dynamic Delivery, users can later download and install those components on demand after they've already installed the base APK of your app.

What is play feature?

Learn how to configure your app for Play Feature Delivery which uses advanced capabilities of app bundles, allowing certain features of your app to be delivered conditionally or downloaded on demand.

What is build in Android?

The Android build system compiles app resources and source code, and packages them into APKs or Android App Bundles that you can test, deploy, sign, and distribute.


1 Answers

I'm having a kind of similar problem. i want to add plugins on runtime without forcing the user to reinstall the app.

I found a very good chapter called "Plugin Patterns" on "The Busy Coder's Guide to Android Development" book. I am still reading it so can't really say if it covers exactly your needs but it contains plenty of information that might be useful for your case.

Here is a sample of the chapter, found on the books web page, so you have an overview of what it covers

For the purposes of this chapter, a “plugin model” refers to an app (the plugin “host”) that is being extended by other apps (the “plugins”) that are largely dedicated to that job.

Certainly, there are plenty of ways that apps can work together without one being a plugin to another. The user’s Web browser is not a plugin of your app when you call startActivity() to view a Web page, for example.

By contrast, the Locale app can be extended via plugins, written either by two forty four a.m. (the authors of Locale) or third parties. These plugins have no real value to the user other than by how they improve what Locale itself can do. This sort of structure, therefore, qualifies as a plugin model.

In particular, this chapter will focus on two general scenarios for wanting a plugin model, though others certainly exist:

You want to allow third parties to extend the capability of your app, much as two forty four a.m. wanted with Locale, or You want to reduce the number of permissions in your core app by delegating some permissions to plugins, so users can “opt into” those permissions

I hope that helps a bit.

like image 122
Adam Avatar answered Oct 10 '22 00:10

Adam