APKParser
APKParser copied to clipboard
Bug and possible fix for parsing APK files manifest data
Example is of Chrome and Chrome beta:
The issue with those seems that it causes attributes to have namespace missing, as such:
<?xml version="1.0" encoding="utf-8"?>
<manifest http://schemas.android.com/apk/res/android:versionCode="398706833" http://schemas.android.com/apk/res/android:versionName="80.0.3987.68" http://schemas.android.com/apk/res/android:compileSdkVersion="29" http://schemas.android.com/apk/res/android:compileSdkVersionCodename="10" package="com.chrome.beta" platformBuildVersionCode="29" platformBuildVersionName="10">
...
Here's the full output of parsing Chrome beta using ApkParser.create(file).manifestXml
:
This is considered as invalid XML.
However, I've found a way to parse their manifest anyway. And it seems to fix this issue too .
I made a test, and it seems that I got it right for manifest files of both normal APK files and split APK files. This code is based on this solution on StackOverflow :
Please check it out.
Here are other sample APK files that the library fails to parse, yet the sample code I wrote did it fine:
All of these are from the Android emulator.