3

I'm working on adding files to an apk file using the aapt tool. So far, i'm able to add files to apk using the following command on CMD from java class:

aapt add -v apk_file_name "dir structure of files to be added"

I want to add files to the assets folder in apk. However, i can add files this way only if they are present in the assets folder inside the tool directory(e.g., D:/AAPT/assets/files). Otherwise it will create the dir structure of the file path i give(e.g, if i give D:/newfolder/test.xml....it will create newfolder/test.xml inside apk which i don't want).

I want to add files from any location on the system to the assets folder in apk. By this i mean that the command i'm using so far is:

aapt add -v example.apk "assets/test.xml"

It will create a dir structure assets/test.xml inside apk


Now, i want something like: aapt add -v example.apk "assets/test.xml" "absolute path of the test.xml on system" it takes the file from the system and creates a dir structure assets/test.xml

So that i don't need to copy the files inside the tools directory everytime thus allowing more flexibility for giving file path.

Does anyone know how to write the command for such a case?

I came to know of -A -S options, but i don't know the right way to use them. Did some hit and trial but not able to add files properly.

PS- running the CMD command from my java class

Rahul
  • 637
  • 5
  • 16

1 Answers1

-1

adding resources to a apk file using aapt.exe tool?

Later in your question, you state that you are trying to add assets to an APK file. Resources are not assets; assets are not resources.

Does anyone know how to write the command for such a case?

Use your favorite ZIP utility. APK files are ZIP archives, and assets are simply files inside of that archive.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @Rahul: As I wrote, use your favorite ZIP utility. You do not need **`aapt`** to add assets to an APK. – CommonsWare Oct 03 '13 at 14:04
  • @CommonsWare Hi, I added text file into .apk file and I resigned it using jarsigner and aligned that apk using zipalign but final .apk does not installing into my device. My device showing application not installed error. May I know problem behind this? – SathishKumar Apr 07 '14 at 05:02
  • 1
    @SathishKumar: I have no idea. – CommonsWare Apr 07 '14 at 11:03
  • @CommonsWare Thank you for you reply and i fixed this issue. I used wrong commend to generate signed apk using jarsigner. – SathishKumar Apr 07 '14 at 12:07