Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

android

apk

In My android application i only need to make a small change in a property file.

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.

like image 728
Prateek Avatar asked Dec 17 '12 07:12

Prateek


2 Answers

To do this, you will have to decompress the packaged APK, and find the string you want to changed. The string may have been encoded or converted to bytecode (Java String) or a binary format (XML String). You will need to figure out whether or not this has been done, and what the new String looks like. 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.

Quite frankly, it'll take you longer to do this than to just recompile the app.

like image 128
Raghav Sood Avatar answered Oct 06 '22 01:10

Raghav Sood


Since you own the source code, unpacking and rebuilding the APK seems to be a waste of time. 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.

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. Please tell us more about your build environment so that we can give more accurate answers.

like image 38
Torben Avatar answered Oct 06 '22 01:10

Torben