Android的:如何手动添加文件到APK? [英] Android: How to manually add a file to apk?

查看:911
本文介绍了Android的:如何手动添加文件到APK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何手动将文件添加到一个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 目录)签署。所以,你需要调用<一个href="http://java.sun.com/javase/6/docs/technotes/guides/security/SecurityToolsSummary.html#jarsigner"相对=nofollow>的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.

这篇关于Android的:如何手动添加文件到APK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆