iBotPeaches / Apktool

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

NullPointerException when Decoding values */* XMLs #1945

Closed maldiva closed 3 years ago

maldiva commented 5 years ago

Information

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

Stacktrace/Logcat

I: Using Apktool 2.3.4 on base.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\PC\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Exception in thread "main" java.lang.NullPointerException
            at brut.androlib.res.data.value.ResEnumAttr.serializeBody(ResEnumAttr.java:56)
           at brut.androlib.res.data.value.ResAttr.serializeToResValuesXml(ResAttr.java:64)
           at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:697)
           at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:263)
           at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131)
           at brut.androlib.ApkDecoder.decode(ApkDecoder.java:124)
           at brut.apktool.Main.cmdDecode(Main.java:164)
           at brut.apktool.Main.main(Main.java:73)

Steps to Reproduce

  1. apktool d base.apk

APK

https://github.com/navigante/base

tprochazka commented 5 years ago

Exactly the same issue just line numbers are different

c:\PJazyky\_Android\Tools\APKTool>apktool.bat d -f ActionDash_1.8.apk
I: Using Apktool 2.3.4 on ActionDash_1.8.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
S: WARNING: Could not write to (C:\Users\tomas\AppData\Local\apktool\framework), using C:\Users\tomas\AppData\Local\Temp\ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
I: Loading resource table from file: C:\Users\tomas\AppData\Local\Temp\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Exception in thread "main" java.lang.NullPointerException
        at brut.androlib.res.data.value.ResEnumAttr.decodeValue(ResEnumAttr.java:73)
        at brut.androlib.res.data.value.ResEnumAttr.convertToResXmlFormat(ResEnumAttr.java:41)
        at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:71)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:697)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:263)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:124)
        at brut.apktool.Main.cmdDecode(Main.java:164)
        at brut.apktool.Main.main(Main.java:73)
KAlO2 commented 5 years ago

Hello, I come here for the same issue. Exception in thread "main" java.lang.NullPointerException at brut.androlib.res.data.value.ResEnumAttr.serializeBody(ResEnumAttr.java:56)

https://github.com/iBotPeaches/Apktool/blob/master/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResEnumAttr.java#L56

Exadra37 commented 5 years ago

So this issue keeps being ignored?

I have the same issue:

apktool decode -f ../../app/release/app-release.apk
I: Using Apktool 2.2.1-dirty on app-release.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/java/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Exception in thread "main" java.lang.NullPointerException
    at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:58)
    at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:516)
    at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:267)
    at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:132)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:108)
    at brut.apktool.Main.cmdDecode(Main.java:166)
    at brut.apktool.Main.main(Main.java:81)

I am on:

$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

apktool was installed with apt.

iBotPeaches commented 5 years ago

@Exadra37 Your build is 2+ years old and dirty and it isn't relevant to this issue.

goodguysoft commented 5 years ago

apktool d tiktok.apk I: Using Apktool 2.4.0 on tiktok.apk I: Loading resource table... W: Unknown data detected. Skipping: 192 byte(s) W: Unknown data detected. Skipping: 32 byte(s) W: Unknown data detected. Skipping: 2032 byte(s) W: Unknown data detected. Skipping: 2448 byte(s) I: Decoding AndroidManifest.xml with resources... S: WARNING: Could not write to (C:\Users\User\AppData\Local\apktool\framework), using C:\Users\User\AppData\Local\Temp\ instead... S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable I: Loading resource table from file: C:\Users\User\AppData\Local\Temp\1.apk I: Regular manifest package... I: Decoding file-resources... I: Decoding values / XMLs... Exception in thread "main" java.lang.NullPointerException at brut.androlib.res.data.value.ResEnumAttr.serializeBody(ResEnumAttr.java:56) at brut.androlib.res.data.value.ResAttr.serializeToResValuesXml(ResAttr.java:64) at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:704) at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:263) at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131) at brut.androlib.ApkDecoder.decode(ApkDecoder.java:124) at brut.apktool.Main.cmdDecode(Main.java:167) at brut.apktool.Main.main(Main.java:76)

goodguysoft commented 5 years ago

Is there any idea what to do?

MIkeeJY commented 5 years ago

Is there any idea what to do?

gilhartman commented 5 years ago

Same issue on https://www.apkmonk.com/download-app/com.safaricom.android.subreg/5_com.safaricom.android.subreg_2019-09-09.apk/

I: Using Apktool 2.4.1-75e4c6-SNAPSHOT on com.safaricom.android.subreg_2019-09-09.apk I: Loading resource table... I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: /Users/gil/Library/apktool/framework/1.apk I: Regular manifest package... I: Decoding file-resources... I: Decoding values / XMLs... Exception in thread "main" java.lang.NullPointerException at brut.androlib.res.data.value.ResEnumAttr.serializeBody(ResEnumAttr.java:56) at brut.androlib.res.data.value.ResAttr.serializeToResValuesXml(ResAttr.java:64) at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:703) at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:260) at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131) at brut.androlib.ApkDecoder.decode(ApkDecoder.java:124) at brut.apktool.Main.cmdDecode(Main.java:170) at brut.apktool.Main.main(Main.java:76)

Tested on apktool 2.4.0 and latest apktool compiled from top of master

Mouradif commented 4 years ago

Same issue here trying to decompile latest Airbnb APK downloaded from https://www.apk4fun.com/apk/7005/

$ apktool d com.airbnb.android-19.45@APK4Fun.com.apk 
I: Using Apktool 2.4.0 on com.airbnb.android-19.45@APK4Fun.com.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
S: WARNING: Could not write to (/home/mkejji/.local/share/apktool/framework), using /tmp instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
I: Loading resource table from file: /tmp/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Exception in thread "main" java.lang.NullPointerException
    at brut.androlib.res.data.value.ResEnumAttr.serializeBody(ResEnumAttr.java:56)
    at brut.androlib.res.data.value.ResAttr.serializeToResValuesXml(ResAttr.java:64)
    at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:704)
    at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:263)
    at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:124)
    at brut.apktool.Main.cmdDecode(Main.java:167)
    at brut.apktool.Main.main(Main.java:76)
iBotPeaches commented 3 years ago

Rebuilding isn't going to happen, but I'll fix the NPE for now.

➜  1945 aapt d resources com.safaricom.android.subreg_2019-09-09.apk | grep '0x7F0903E1'
➜  1945 

This is is reference a parent resource that does not exist. So not really sure at all. Its not even a resource that we can make a dummy resource for. PR linked above for NPE, once merged this will close.

georgedenial commented 2 years ago

Well I was working on a clients project and faced the same issue. I am not sure If its safe to share the link here.