APP下载

Android动态加载技术

2016-11-02常煜邓飞

电脑知识与技术 2016年23期

常煜 邓飞

摘要:Android动态加载技术指应用在运行的时候通过加载一些本地不存在的可执行文件实现一些特定的功能,而且这些可执行文件是可以替换的。通过对Android动态加载技术的原理进行分析,解决关键性问题,实现Android动态加载技术。该技术可以解决Android应用开发到一定规模时APK安装包过大,功能模块过多,没有办法选择性加载所需模块的问题,既可以显著提高应用新版本的覆盖率,也可以用来修复紧急BUG。

关键词:Android;动态加载;APK

中图分类号:TP311 文献标识码:A 文章编号:1009-3044(2016)23-0049-02

Abstract: Android dynamic loading technology refers to loading certain executable and substitutable files that do not exist locally while the application is running, thus specific functions being achieved. The implementation of this technology can be realized through the analysis of its principles and the solving of key problems. Problems like too large APK installation package, too many function modules, and difficulties in selectively loading required modules when Android application is developed to a certain scale can be well resolved by this technology. The coverage of the new version of the application can be significantly enlarged and emergency bug can also be fixed through this technology.

Key words: Android; dynamic loading; APK

1 背景

动态加载[1](Dynamic Loading)是一种程序运行机制,能让计算机程序在运行时(而不是编译时)装载库(或者其他二进制对象)到内存中,然后检索库中函数和变量的地址,并执行这些函数或访问这些变量,且能在不需要时将库从内存中卸载。与静态链接相比,动态加载具有增加程序灵活性、节约内存空间的优点。Android动态加载[2]是指应用在运行的时候通过加载一些本地不存在的可执行文件实现一些特定的功能,而且这些可执行文件是可以替换的。Android中动态加载的核心思想是动态调用外部的dex文件,极端的情况下,Android APK自身带有的dex文件只是一个程序的入口(或者说是空壳),所有的功能都是通过从服务器下载最新的dex文件完成[3]。

Android动态加载技术能够解决Android应用开发到一定规模时APK安装包过大,功能模块过多,没有办法选择性加载所需模块的问题,达到不安装新APK就升级APP的目的,既可以显著提高应用新版本的覆盖率,也可以减少服务器对旧版本接口兼容的压力,同时也可以用来修复一些紧急BUG。……

登录APP查看全文