重新打包APK文件包含自定义资源 - 使用什么样的构建工具? [英] Repackage APK file to contain custom assets - what build tool to use?

查看:375
本文介绍了重新打包APK文件包含自定义资源 - 使用什么样的构建工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:这是旧的文章,以下引用破 AAPT 版本将过时

Update: This is an old post, and references below to broken aapt versions will be out of date.

,我存储在我的应用程序的资产目录中的自定义文本字段。

Based on previous feedback, I am storing custom text fields in the assets directory of my app.

我将写的应用程序,利用在一个资产文件缺省用户的详细信息,并在客户端希望重建该应用为每个用户,包括在资产文件该用户的详细信息。

I will write the app, using default user details in an asset file, and the client would like to rebuild the app for each user, including that user's details in the asset file.

(我知道这是方法有一些严重的不足之处,但客户仍然热衷于做这种方式 - 看<一href="http://stackoverflow.com/questions/4783160/embed-login-details-in-apk-file-different-for-each-user-or-other-options">Embed登录信息的APK文件,为每个用户不同(或其他的选择吗?))

(I am aware this is method has some serious shortcomings, but the client is still keen to do it in this way - see Embed login details in APK file, different for each user (or other options?))

这个问题涉及到的麻烦我有重建的APK文件,一旦我解压缩它,并更新了自定义的资源文件。我很相信我失去了一些东西小,但是,我发现这些方法的文档和帖子是不是一个新人足够的帮助。

This question relates to troubles I am having with rebuilding the APK file, once I have unzipped it, and updated the custom asset file. I am quite convinced I am missing something small, however, the documentation and posts I have found on these methods are not helpful enough for a newcomer.

  1. AAPT - Android SDK中的工具:不幸的是对android的文档[以下链接2]使用AAPTandroid的文档是非常有限的。控制台命令-help显示更多的信息。当试图用它来只是一个文件添加到test.apk,它最终删除原,并创建一个只包含我尝试添加该文件的新文件test.apk.zip。我一直没能找到正确的命令行组合采取一种解压的APK和重新包装 - 这将是我的第一个奖

  1. aapt - Android sdk tool: Unfortunately the android docs on "Using aapt" on the android docs [link 2 below] are very limited. The console command -help shows a bit more info. When trying to use it to just add a file to the test.apk, it ends up deleting the original, and creating a new file test.apk.zip containing only the file I tried to add. I have not been able to find the correct command line combination to take an unzipped apk and repackage it - that would be my first prize.

apkbuilder - Android SDK中的工具:首先这个工具是pcated德$ P $,这是一个不利点吧。我也不能让它跟我有什么在解压后的文件夹中工作。我想我错过了pre-apkbuilder步骤,因为apkbuilder要求的资源zip压缩包,和我有一个资源文件夹。

apkbuilder - Android sdk tool: Firstly this tool is deprecated, which is a negative point for it. I also can't get it to work with what I have in that unzipped folder. I think I'm missing a pre-apkbuilder step because apkbuilder asks for a resource zip archive, and I have a resource folder.

蚂蚁 - 构建工具的类似的帖子说,建立与蚂蚁,而不是使用Android的工具。我有麻烦蚂蚁工作。要获取Ant来与Android [链接如下3]工作的一个特定的链接看起来很有希望,但看起来是一个不同的Andr​​oid SDK中(我的是由机器人产生的build.xml看起来不一样了他)。不幸的是,我知道一点关于蚂蚁,时遇到了问题成为专家不足以解决我目前的问题。
继低于NickT的解决方案 - 运行ant脚本给我的错误
的taskdef类com.android.ant.SetupTask无法使用的类加载器AntClassLoader [] 的发现。
我已经发现了一些网上的引用此错误,已经证实local.properties具有指向我的Andr​​oid SDK中的安装文件夹(sdk.dir = /应用/ Android的SDK-mac_86)的sdk.dir设置。

ant - build tool: Other similar posts say to build with ant, rather than using the android tools. I am having trouble getting ant to work. One particular link to Getting Ant to Work with Android [link 3 below] looks promising but looks like it is for a different android sdk (my build.xml that is generated by android looks different to his). Unfortunately I know little about ant, and am having trouble becoming expert enough to solve my current issue.
Further to NickT's solution below - running the ant script gives me the error
taskdef class com.android.ant.SetupTask cannot be found using the classloader AntClassLoader[].
I have found some references online to this error, have confirmed that local.properties has an sdk.dir setting that is pointing to my android sdk install folder (sdk.dir=/Applications/android-sdk-mac_86).

?????:有可能是我没有列出/发现了一些其他的选择,我有兴趣听到有关。

?????: There might be some other option that I have not listed / discovered, which I would be interested in hearing about.

我意识到钻研那些通常掩盖了我的IDE齿轮可能导致diffuculties。但我知道,有很多的,这样用户可以做很多的这些事情,我希望我得到了一些人的利益。感谢您的帮助。

I realize that delving into the gears that are normally covered up by my ide can lead to diffuculties. But I know that a lot of the SO users can do many of these things, and I hope I get the interest of some of them. Thanks for any help.

PS,我无法发布超过1超级链接还,所以我已经包括了这些地址,以显示我的问题的详细信息。

PS, I am not able to post more than 1 hyperlink yet, so I have included these addresses to show more info to my question.

(1): stackoverflow.com/questions/4783160/embed-login-details-in-apk-file-different-for-each-user-or-other-options

(1): stackoverflow.com/questions/4783160/embed-login-details-in-apk-file-different-for-each-user-or-other-options

(2):developer.android.com/guide/developing/tool​​s/aapt.html

(2): developer.android.com/guide/developing/tools/aapt.html

(3):www.disgr​​untledrats.com/?p=27

(3): www.disgruntledrats.com/?p=27

推荐答案

要回答我的问题跟我们最后选​​择的方法,以及备案:

To answer my own question with the method we finally chose, and "for the record":

我无法让蚂蚁正常工作对我来说(我缺乏了解)。

I was unable to get Ant working correctly for me (my lack of understanding).

我最终使用的AAPT工具。它的工作原理根据Android的SDK文档,真的是很简单的使用方法:

I ended up using the aapt tool. It works as per the Android sdk documentation and really is quite simple to use:

aapt add -v Test.apk "assets/readme.txt"

这将添加一个readme.txt文件(我们在当前正在运行的文件夹,称为资产的子文件夹中存储它。如果你想存储新的文件在其他地方,AAPT确实提供了命令行开关指定)

This will add a readme.txt file (we were storing it in a subfolder of the current running folder, called assets. If you want to store the new file somewhere else, aapt does offer a command line switch to specify that)

然而,也有一些注意事项:

  1. 在我无法得到它的工作在签署APK文件。
  2. 在某些版本的AAPT 不工作正确!他们不承认的子文件夹...
  1. I couldn't get it to work on signed APK files.
  2. some versions of aapt don't work properly! They don't recognise the subfolder...

要解决1:

  1. 从Eclipse导出的APK为一个无符号APK。
  2. 使用密钥工具生成一个密钥(见Android开发文档)。
  3. 使用AAPT。
  4. 登入的使用的jarsigner APK。

要解决2:

我不能真正帮助与此有关。该SDK(在Mac)的每一个版本,我试图下载包含不承认的子文件夹的AAPT工具。一位同事下载的工作版本,但我们仍然不知道哪个版本是他下载的,所以我们保留了这个神奇的副本,并重新命名,并会使用它,直到我们找到一种可行的新版本。

I can't really help with this. Every version of the SDK (on Mac) I tried to download included an aapt tool that did not recognize the subfolders. A colleague downloaded a version that worked, but we could still not figure out which version it was that he downloaded, so we kept this "magic" copy and renamed it and will be using it until we find a new version that works.

这篇关于重新打包APK文件包含自定义资源 - 使用什么样的构建工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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