Skip to content

parse WhatsApp get "AssertionError: reserved must be zero" #93

@deafwolf

Description

@deafwolf

Hi,

When I tried to parse WhatApp.apk, it threw “AssertionError: reserved must be zero.”
I downloaded apk from https://www.whatsapp.com/android

In [1]: from pyaxmlparser import APK

In [2]: apk = APK('WhatsApp.apk')

In [3]: apk.icon_data
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/pyaxmlparser/core.py:1478, in APK.get_android_resources(self)
   1477 try:
-> 1478     return self.arsc["resources.arsc"]
   1479 except KeyError:

KeyError: 'resources.arsc'

During handling of the above exception, another exception occurred:

AssertionError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 apk.icon_data

File ~/.local/lib/python3.10/site-packages/pyaxmlparser/core.py:2081, in APK.icon_data(self)
   2079 @property
   2080 def icon_data(self):
-> 2081     app_icon_file = self.get_app_icon()
   2082     if not app_icon_file:
   2083         return None

File ~/.local/lib/python3.10/site-packages/pyaxmlparser/core.py:566, in APK.get_app_icon(self, max_dpi)
    563 if not app_icon:
    564     app_icon = self.get_attribute_value('application', 'icon')
--> 566 res_parser = self.get_android_resources()
    567 if not res_parser:
    568     # Can not do anything below this point to resolve...
    569     return None

File ~/.local/lib/python3.10/site-packages/pyaxmlparser/core.py:1484, in APK.get_android_resources(self)
   1480 if "resources.arsc" not in self.zip.namelist():
   1481     # There is a rare case, that no resource file is supplied.
   1482     # Maybe it was added manually, thus we check here
   1483     return None
-> 1484 self.arsc["resources.arsc"] = ARSCParser(self.zip.read("resources.arsc"))
   1485 return self.arsc["resources.arsc"]

File ~/.local/lib/python3.10/site-packages/pyaxmlparser/arscparser.py:120, in ARSCParser.__init__(self, raw_buff)
    117     self.packages[package_name].append(ARSCResTypeSpec(self.buff, pc))
    119 elif pkg_chunk_header.type == const.RES_TABLE_TYPE_TYPE:
--> 120     a_res_type = ARSCResType(self.buff, pc)
    121     self.packages[package_name].append(a_res_type)
    122     self.resource_configs[package_name][a_res_type].add(a_res_type.config)

File ~/.local/lib/python3.10/site-packages/pyaxmlparser/arscutil.py:156, in ARSCResType.__init__(self, buff, parent)
    154 self.flags, = unpack('<B', buff.read(1))
    155 self.reserved = unpack('<H', buff.read(2))[0]
--> 156 assert self.reserved == 0, "reserved must be zero!"
    157 self.entryCount = unpack('<I', buff.read(4))[0]
    158 self.entriesStart = unpack('<I', buff.read(4))[0]

AssertionError: reserved must be zero!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions