简体   繁体   English

可以更改Android APK文件中的资源而无需重建吗?

[英]Can resources in an Android APK-file be changed without rebuilding?

In My android application i only need to make a small change in a property file. 在我的Android应用程序中,我只需要在属性文件中进行一些小改动。

For example: 例如:

In my property file ,there is a welcome message for specific client. 在我的属性文件中,有一个特定客户端的欢迎消息。 So,i have to change only client name in my application. 所以,我必须在我的应用程序中只更改客户端名称。

But the problem is ,I have to do that in source and then have to build every time for every client. 但问题是,我必须在源代码中执行此操作,然后必须每次为每个客户端构建。

Is there any way to change it directly in .apk file without creating a build again & again. 有没有办法直接在.apk文件中更改它,而无需再次创建构建。

To do this, you will have to decompress the packaged APK, and find the string you want to changed. 为此,您必须解压缩打包的APK,并找到要更改的字符串。 The string may have been encoded or converted to bytecode (Java String) or a binary format (XML String). 该字符串可能已被编码或转换为字节码(Java String)或二进制格式(XML String)。 You will need to figure out whether or not this has been done, and what the new String looks like. 您需要确定是否已完成此操作,以及新String的外观。 You will then need to take the string you want to replace it with, and encode it the same way before swapping them. 然后,您需要获取要替换它的字符串,并在交换它们之前以相同的方式对其进行编码。

After you've done all this, you must recompress the app and run the signing tool and zip align manually before it is usable in an apk format again. 完成所有这些操作后,您必须重新压缩应用程序并运行签名工具并手动压缩对齐,然后再以apk格式使用。

Quite frankly, it'll take you longer to do this than to just recompile the app. 坦率地说,这样做需要更长的时间才能重新编译应用程序。

Since you own the source code, unpacking and rebuilding the APK seems to be a waste of time. 由于您拥有源代码,解压缩和重建APK似乎是浪费时间。 You should solve this problem in the original build process. 您应该在原始构建过程中解决此问题。

If you building your APK-packages manually with Eclipse, then you should look into setting up some automated build system (Ant, Maven, etc.) and provide the client name as a parameter to the build script. 如果您使用Eclipse手动构建APK包,那么您应该考虑设置一些自动构建系统(Ant,Maven等)并将客户端名称作为参数提供给构建脚本。

If you are already using Ant or Maven, then those tools already provide methods for replacing a tag in a text file with a property value before compiling. 如果您已经在使用Ant或Maven,那么这些工具已经提供了在编译之前使用属性值替换文本文件中的标记的方法。 Please tell us more about your build environment so that we can give more accurate answers. 请告诉我们有关您的构建环境的更多信息,以便我们提供更准确的答案。

Use the Android APK Tool . 使用Android APK工具

To quote the description 引用描述

It is a tool for reverse engineering 3rd party, closed, binary Android apps. 它是逆向工程第三方,封闭式二进制Android应用程序的工具。 It can decode resources to nearly original form and rebuild them after making some modifications; 它可以将资源解码为近乎原始的形式,并在进行一些修改后重建它们;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM