如何将XML转换为Android二进制XML

前端之家收集整理的这篇文章主要介绍了如何将XML转换为Android二进制XML前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在创建一个可以部署 Android应用程序的软件,但位于apk文件中的AndroidManifest是自定义二进制XML格式.我想要找出的是,是否有一个工具可以让我将自己的AndroidManifest.xml文件添加到apk中(在添加时将其转换为AXML),或者是在任何地方解释的格式,以便我可以创建我的拥有转换器

解决方法

使用Android打包工具(aapt.exe)计算出来

aapt.exe package -f -m -J src -M AndroidManifest.xml -S res -A assets  -0 "" -I android.jar -F MyApp.apk

根据docs

-f
    force overwrite of existing files

-m
    make package directories under location specified by -J

-J
    specify where to output R.java resource constant definitions

-M
    specify full path to AndroidManifest.xml to include in zip

-S
    directory in which to find resources. Multiple directories will be scanned and the first match found (left to right) will take precedence

-A
    additional directory in which to find raw asset files

-0
    specifies an additional extension for which such files will not be stored compressed in the .apk. An empty string means to not compress any files at all.

-I
    add an existing package to base include set

-F
    specify the apk file to output

这需要一个普通的xml清单并将其打包成二进制XML并将其插入到apk中.

不幸的是,它需要存在资源和资产(如果您在清单文件本身中引用它们).我还必须将任何其他数据添加回apk文件.不理想,但它至少起作用

猜你在找的XML相关文章