Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

Restore "Last-Modified" time during apk generation.

Open yankarinRG opened this issue 6 years ago • 4 comments

Information

  1. Apktool Version (apktool -version) - 2.4.0
  2. Operating System (Mac, Linux, Windows) - Windows 10 64-bit
  3. APK From? (Playstore, ROM, Other) - APKMirror

Steps to Reproduce

  1. apktool d <app>.apk
  2. Edit a file. For example, AndroidManifest.xml
  3. apktool b <app> -o <new_app>.apk
  4. Now open both .apk and <new_app>.apk with 7-Zip FIle Manager or similar and compare both edited files, in our example, AndroidManifest.xml: the original file, in .apk will have the bare minimum needed metadata and last edited date of 01/01/2009, while the edited file, in <new_app>.apk will have more metadata (thus more overhead) than the original file.

N.B. this is just an example, all files inside the apk (zip), regardless if edited or not, will have those added metadata, at least the current date instead of 01/01/2009.

Performing a zipalign does not solve the issue.

Zip file format FIle headers

APK

If this APK can be freely shared, please upload/attach a link to it. Google Phone

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes
  2. If you are trying to install a modified apk, did you resign it? Yes
  3. Are you using the latest apktool version? Yes

Attached pictures:

In red, you can notice that by removing from the apk (zip) the file android-support-multidex.version and putting it back again, metadata is added. In green , date difference between original and edited app.

app app_new

yankarinRG avatar Jul 30 '19 15:07 yankarinRG

So is there a bug you are encountering with this behavior?

iBotPeaches avatar Aug 02 '19 01:08 iBotPeaches

Not that I know or have discovered, and I think there aren't. It's just that it would be cleaner because the apk file would be more similar to a genuine apk.

yankarinRG avatar Aug 02 '19 13:08 yankarinRG

Okay, I did some investigation and we could probably do this by recording the LastModified time of files during read, then re-set them back to that value after writing zip file.

However, system is not really designed to do that at all. So marking as feature request for backlog.

iBotPeaches avatar Aug 17 '19 11:08 iBotPeaches

Hello, I think that this feature is very important for reproducible rebuilds. Could you please make it possible to set that date to an arbitrary value?

mimi89999 avatar Jan 26 '21 11:01 mimi89999