Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: "ParserException: Unexpected chunk Type: 0x206" #1

Open
AndroidDeveloperLB opened this issue Jun 5, 2022 · 3 comments
Open

Bug: "ParserException: Unexpected chunk Type: 0x206" #1

AndroidDeveloperLB opened this issue Jun 5, 2022 · 3 comments

Comments

@AndroidDeveloperLB
Copy link
Owner

AndroidDeveloperLB commented Jun 5, 2022

I got this on the sample on Pixel 6 with Android 12.1 beta 3 :

can't parse apk for "android" in: "/system/framework/framework-res.apk" - exception:net.dongliu.apk.parser.exception.ParserException: Unexpected chunk Type: 0x206 isSystemApp?true

There are some similar issues on the original repository that were fixed:
https://github.com/hsiafan/apk-parser/issues?q=Unexpected+chunk+Type

Meaning:

hsiafan/apk-parser#52
hsiafan/apk-parser#54
hsiafan/apk-parser#40
hsiafan/apk-parser#49
hsiafan/apk-parser#66
hsiafan/apk-parser#89
hsiafan/apk-parser#111

It seems the original author told me to ignore some chunk types, such as 0x0204 :
hsiafan/apk-parser#96 (comment)
And that it was ignored by treating it in ChunkType class, treating it as NullHeader in ResourceTableParser class.

The proper solution might be related to looking here:
https://android.googlesource.com/platform/frameworks/base/+/master/libs/androidfw/include/androidfw/ResourceTypes.h

Of course, we could ignore this too. I just hope it won't cause an issue.

Attached the sample APK that is problematic, giving this error:

framework-res.zip

@AndroidDeveloperLB AndroidDeveloperLB changed the title "ParserException: Unexpected chunk Type: 0x206" for "ParserException: Unexpected chunk Type: 0x206" Jun 5, 2022
@AndroidDeveloperLB AndroidDeveloperLB changed the title "ParserException: Unexpected chunk Type: 0x206" Bug: "ParserException: Unexpected chunk Type: 0x206" Jun 5, 2022
@AndroidDeveloperLB
Copy link
Owner Author

Tried to Fix by using the same workaround as 0x0204 , and also renamed the constants according to the Android source code.

Sadly it caused a different issue after this change:

can't parse apk for "android" in: "/system/framework/framework-res.apk" - exception:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String net.dongliu.apk.parser.struct.resource.PackageHeader.getName()' on a null object reference isSystemApp?true

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String net.dongliu.apk.parser.struct.resource.PackageHeader.getName()' on a null object reference
at net.dongliu.apk.parser.struct.resource.ResourcePackage.(ResourcePackage.java:28)
at net.dongliu.apk.parser.parser.ResourceTableParser.readPackage(ResourceTableParser.java:87)
at net.dongliu.apk.parser.parser.ResourceTableParser.parse(ResourceTableParser.java:76)
at com.lb.apkparserdemo.apk_info.ApkInfo$Companion.getApkInfo(ApkInfo.kt:59)
at com.lb.apkparserdemo.MainActivity$performTest$1.invoke(MainActivity.kt:77)
at com.lb.apkparserdemo.MainActivity$performTest$1.invoke(MainActivity.kt:43)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

@ujjwalkirorimal
Copy link

Any updates on this?

@AndroidDeveloperLB
Copy link
Owner Author

@ujjwalkirorimal Sadly I'm not an expert on the implementation of the parsing. I forked it to:

  1. Fix what I can
  2. Have others that might be able to help
  3. Convert to Kotlin to make it simpler, shorter, and maybe have less bugs. I did this partially but then I reached some places that are harder and will take a lot of effort, because I'm not sure what's allowed there (nullability for example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants