iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
20.04k stars 3.57k forks source link

Just won't recompile resources no matter what. #2005

Closed Erquint closed 5 years ago

Erquint commented 5 years ago

Information

PS C:\x> [System.Environment]::OSVersion.VersionString
Microsoft Windows NT 10.0.17134.0
PS C:\x> apktool --version
2.3.4
PS C:\x> java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

PixelExperience Santoni Pie (Android 9) Basically AOSP with some Google Pixel extras. framework-res.apk

No framework installed

PS C:\x> apktool d framework-res.apk
I: Using Apktool 2.3.4 on framework-res.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
PS C:\x> apktool b framework-res
I: Using Apktool 2.3.4
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
brut.androlib.AndrolibException: brut.common.BrutException: could not exec: […]

Cleaning up

PS C:\x> rmdir framework-res -r

Trying again with framework (it is itself one AFAII)

PS C:\x> apktool if framework-res.apk
I: Framework installed to: C:\Users\Erquint\AppData\Local\apktool\framework\1.apk
PS C:\x> apktool d framework-res.apk
I: Using Apktool 2.3.4 on framework-res.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
PS C:\x> apktool b framework-res
I: Using Apktool 2.3.4
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
brut.androlib.AndrolibException: brut.common.BrutException: could not exec: […]

Omitted from both snippets are the array contents (replaced by ). Full console output in this gist.

Frameworks

It's the framework-res.apk I'm trying to recompile pulled with ADB directly from the phone with PixelExperience installed and seemingly working alright.

APK

Same file

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yep, that's what I did.
  2. If you are trying to install a modified apk, did you resign it? Not trying that, no.
  3. Are you using the latest apktool version? As far as your website made me aware of.

Purpose and some weird quirks

I just want to edit one single XML file in there. If I could just decode and encode separate binary files without messing with the whole APK — that would be wonderful. At least tell me what algorithm it is encoded with so that I can find/make a tool that works with just that.

So apktool breaks when trying to compile the APK on my Windows 10 if I decompile it with resources (no -r key). Weirdly enough, it breaks trying to decompile this APK on an Ubuntu subsystem. I never expected editing one tiny XML being this complicated an ordeal.

iBotPeaches commented 5 years ago

If I could just decode and encode separate binary files without messing with the whole APK — that would be wonderful.

Not possible. Files reference others.

At least tell me what algorithm it is encoded with so that I can find/make a tool that works with just that.

Android XML (AXML)

So apktool breaks when trying to compile the APK on my Windows 10 if I decompile it with resources (no -r key).

Duplicate of #1272, command is too long for Windows

Weirdly enough, it breaks trying to decompile this APK on an Ubuntu subsystem.

Don't see any logs of this to comment.

I never expected editing one tiny XML being this complicated an ordeal.

Welcome to reverse engineering, and not even RE. RE + Rebuild.