androguard: ResParserError: res1 must be zero!

With any recently downloaded APK from Google Play console (universal APK, archive APK) I can’t decode resources.arsc. I attached sample archive APK, but it crash with universal APK too. APK created directly by Gradle task doesn’t cause it.

> androguard --debug arsc 240307133-archived.apk

2024-03-12 16:28:27.029 | INFO     | androguard.core.apk:_apk_analysis:312 - Starting analysis on AndroidManifest.xml
2024-03-12 16:28:27.124 | INFO     | androguard.core.apk:_apk_analysis:369 - APK file was successfully validated!
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\androguard\core\apk\__init__.py", line 1543, in get_android_resources
    return self.arsc["resources.arsc"]
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'resources.arsc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python312\Scripts\androguard.exe\__main__.py", line 7, in <module>
  File "C:\Python312\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\androguard\cli\cli.py", line 169, in arsc
    arscobj = a.get_android_resources()
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\androguard\core\apk\__init__.py", line 1549, in get_android_resources
    self.arsc["resources.arsc"] = ARSCParser(self.zip.read("resources.arsc"))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\androguard\core\axml\__init__.py", line 1471, in __init__
    self.packages[package_name].append(ARSCResTypeSpec(self.buff, pc))
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\androguard\core\axml\__init__.py", line 2339, in __init__
    raise ResParserError("res1 must be zero!")
androguard.core.axml.ResParserError: res1 must be zero!

System Information

  • Androguard Version: 4.1.0
  • Python Version: 3.12.2
  • Operating System: Windows 10 Pro x64 22H2

Attachments

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks, your update makes sense to me! Since this issue is related to AAB, I wonder if the bundletool source might give some insight to what the new usages of res0 and res1 are?

hi @ajinabraham, will aim to release a patch version over the next days. It still under consideration whether the current fix might affect some other cases but in theory for all non split/universal apks it should work fine.