Android的:如何手动添加文件到APK?文件、Android、APK

2023-09-12 11:19:44 作者:离线请留言

如何手动将文件添加到一个Android APK包?

How do I manually add a file to an Android APK package?

推荐答案

这是APK是一个jar这是一个zip。所以,你可以使用操纵拉链任何工具。

An apk is a jar which is a zip. So you can use any tool that manipulates zips.

有一个更加复杂但是:Android平台要求在APK中的所有文件(除了在文件META-INF 目录)签署。所以,你需要调用的jarsigner 再次签署所有软件包。那么你也应该叫 zipalign 了。

There is an added complication however: the Android platform requires all files in the apk (except for the files in the META-INF directory) to be signed. So you need to call jarsigner again to sign all packages. You should then also call zipalign again.

您必须签署与用于签署原来的apk相同的密钥修改后的APK。这是签名的整点:它指示包还没有被篡改,而不签名者的批准。 (其实,你可以使用不同的密钥签名,但随后你将无法访问由原始应用程序或反之亦然产生的任何数据。)

You must sign the modified apk with the same key that was used to sign the original apk. This is the whole point of the signature: it indicates that the package has not been tampered with without the approval of the signer. (Actually, you can sign with a different key, but then you won't be able to access any data that was produced by the original application or vice versa.)

配备了Android开发工具包的Ant脚本包含自动化运行的jarsigner和zipalign。

The ant scripts provided with the Android development kit contain automation to run jarsigner and zipalign.