Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify the data in the assets folder in existing apk programmatically? [duplicate]

I want to replace one file in the assets folder with generated apk(in the assets folder there is sample.txt file after generating the apk i want to change the data in that file and regenerate the new apk ).

===> old APK+modified(sample.txt)=newApk

How to do this?

like image 487
KomalG Avatar asked Jun 08 '15 11:06

KomalG


People also ask

How do I change the value of an APK file?

To edit the files inside, you'll need to decompile (and then recompile) the package using APKtool on a computer. Editing APK files requires knowledge of Java, as well as the file systems on both Windows and Android. This should only be done by advanced users.

What are assets in APK?

Assets provide a way to add arbitrary files like text, XML, HTML, fonts, music, and video in the application. If one tries to add these files as “resources“, Android will treat them into its resource system and you will be unable to get the raw data. If one wants to access data untouched, Assets are one way to do it.

What does an Android APK file contains explain any two components?

An APK file contains all of a program's code (such as .dex files), resources, assets, certificates, and manifest file. As is the case with many file formats, APK files can have any name needed, but it may be required that the file name ends in the file extension for being recognized as such.


1 Answers

An APK file is a ZIP archive, and assets are not modified as part of the build process. So, on your development machine, you can:

  • unZIP the APK file
  • replace your assets
  • ZIP the result back into an APK file
  • use jarsigner to sign the APK with your production keystore
  • use zipalign to align the results on four-byte boundaries for faster loading at runtime
like image 200
CommonsWare Avatar answered Sep 28 '22 03:09

CommonsWare