Android loads modules dynamically

I want to write an Android application that can be expanded using modules (Android libraries). Modules must load at run time. Therefore, they will be downloaded from the URL and stored in the directory. Modules are aar files.

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

I know that you can simply load the contained .jar classes using URLClassLoader. But I can not load the layout, line, ... resources. Hm

Does anyone know how to solve this?

EDIT:

I found several related topics:

This does not seem to work due to the response from the first link. Hope I'm wrong about that.

+6
source share
1 answer

I have the same problem. I want to add plugins at runtime without forcing the user to reinstall the application.

I found a very good chapter called “Plugin Templates” in the “ Busy Code for Android” section of the book . I’m still reading it, so I can’t say if it covers your needs exactly, but it contains a lot of information that can be useful for your business.

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

For the purposes of this chapter, the “plug-in model” refers to an application (“host” plug-in) that is expanded by other applications (“plug-ins”) that are largely dedicated to this work.

Of course, there are many ways that applications can work together without one plugin for another. Users web browser is not a plugin of your application when you call startActivity () to view a web page, for example.

In contrast, the Locale application can be expanded through plugins, written either for two forty-four hours (authors of Locale), or for a third of the party. These plugins have no real value to the user, except they improve what Locale itself can do. Such a structure, therefore, qualifies as a plug-in model.

In particular, this chapter will focus on two common scenarios for the wishing plug-in model, although others certainly exist:

Do you want to allow third parties to expand the capabilities of your application, just like two forty-four in the morning, with Locale, or you want to reduce the number of permissions in your main application by delegating some permissions for plugins so that users can “choose” these permissions

Hope this helps a bit.

0
source

Source: https://habr.com/ru/post/977644/


All Articles