Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use DL Framework to realize dynamic loading in Android

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to use DL framework to achieve dynamic loading in Android". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The principle of dynamic loading:

Android program is mainly written by java code, so android program has some characteristics of java language, such as reflection mechanism, so we can use reflection mechanism to achieve dynamic loading of the program, through the external to call the uninstalled apk code. The reflection mechanism in the Java program is mainly to load the Class that you want to inject into Jvm through ClassLoader, while the dynamic loading of android is similar to loading the apk file into the virtual machine through DexClassLoader.

Today, we will mainly introduce a dynamic loading framework of android: DL dynamic loading framework.

The framework is jointly developed by several students on github. You can download the source code on github. Plug-in android development can be achieved through the DL framework, and online problems can be fixed through real-time hot patches. There is no need for users to download the new version to complete the function online. So what should we know about the use of the DL framework?

First of all, we need to understand that there are three modes of DL usage:

1. Depend_on_host: the plug-in relies entirely on the host's schema and is suitable for situations where the host's source code is available.

2. Depend_on_interface: the plug-in partly depends on the host's pattern, or the plug-in relies on the interface provided by the host, which is suitable for situations where the host's interface can be obtained.

3. Main: plug-ins do not rely on the host pattern, which is recommended by DL.

The above three modes can be adapted to different development situations:

Mode 1. The plug-in relies entirely on the host's pattern and is suitable for situations where the host's source code is available. This mode is generally used within the company, and the plug-in can access all the code of the host. However, the coupling between the plug-in and the host is relatively high. As soon as the host moves, the plug-in must move, which is more troublesome.

Mode 2. The plug-in partly depends on the host's pattern, or the plug-in relies on the interface provided by the host, which is suitable for situations where you can get the host's interface. In this mode, the host releases some interfaces and implements some interfaces, and then calls them to the plug-in so that the plug-in can access some of the host's services, and so on.

Mode 3. This is the mode recommended by DL, and the corresponding project directory is main. In this mode, the host and plug-in do not need to communicate, they are developed independently, the host references DL's jar package (dl-lib.jar), and the plug-in also needs to reference DL's jar package, but cannot be placed in the plug-in project's libs directory.

This is the end of the content of "how to use the DL framework to achieve dynamic loading in Android". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report