Pregunta

I need to add some resource files to an existed .APK file. I wrote a program in Java Se which using ZipInputStream and ZipOutputStream to insert files into assets/myfiles and it works perfectly but when I want to install my new .APK file on my tablet it failed to install! Is there any signature that I should add to new files and how?

¿Fue útil?

Solución

Yes ofcourse you will have to sign the apk files after adding the files externally. If you want to automate the building process and add files to your apk file on building time then

What I would suggest is that

i. Try to build and sign the apk file via ant script more information can be found here: http://developer.android.com/tools/building/building-cmdline.html

You will notice from the above link that you will have to run the command "ant release" from command line to build the project.

ii. Create a batch file (or a .sh file for linux) that will run the ant command.

ii. Then add files to the project directory for example the asset/ folder (You will have to write another program to add the files instead of the ZipStreams you already wrote).

This new program will add files to your directory and then execute your batch file which will then run the ant command.

Notice that the ant release command also signs the resulting apk file. In this way you will automate the process of adding files to your resulting apk file.

But there is one tricky part is to when you run the ant script it prompts you to enter your alias password you will have to a bit of search on how to add this password to your ant script. (Shouldn't be difficult)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top