APKParser icon indicating copy to clipboard operation
APKParser copied to clipboard

Bug and possible fix for parsing APK files manifest data

Open AndroidDeveloperLB opened this issue 4 years ago • 1 comments

Example is of Chrome and Chrome beta:

chrome and chrome beta.zip

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 :

chromeBetaManifestContent.zip

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 :

ApkManifestFetcher.zip

Please check it out.

AndroidDeveloperLB avatar Jan 25 '20 09:01 AndroidDeveloperLB

Here are other sample APK files that the library fails to parse, yet the sample code I wrote did it fine:

problematicApkFiles.zip

All of these are from the Android emulator.

AndroidDeveloperLB avatar Jan 25 '20 10:01 AndroidDeveloperLB