Bug: sometimes can't parse APK files
Closed this issue · 3 comments
AndroidDeveloperLB commented
I wanted to check how well the library works, so I just let it parse all of the installed apps:
AsyncTask.execute {
Log.d("AppLog", "getting all package infos:")
var startTime = System.currentTimeMillis()
val installedPackages = packageManager.getInstalledPackages(0)
var endTime = System.currentTimeMillis()
Log.d("AppLog", "time taken: ${endTime - startTime}")
startTime = endTime
for (packageInfo in installedPackages) {
val apkFilePath = packageInfo.applicationInfo.publicSourceDir
Log.d("AppLog", "getting info of : {${packageInfo.packageName} - $apkFilePath")
val apkFile = ApkFile(apkFilePath)
Log.d("AppLog", "apkFile.apkMeta:${apkFile.apkMeta}")
}
endTime = System.currentTimeMillis()
Log.d("AppLog", "time taken: ${endTime - startTime}")
}
When it reached this, it got an exception:
getting info of : {com.android.documentsui - /system/priv-app/DocumentsUI/DocumentsUI.apk
This is the exception:
2019-06-07 23:50:48.204 2588-2629/com.android.myapplication E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.android.myapplication, PID: 2588
net.dongliu.apk.parser.exception.ParserException: Unexpected chunk Type: 0x204
at net.dongliu.apk.parser.parser.ResourceTableParser.readChunkHeader(ResourceTableParser.java:223)
at net.dongliu.apk.parser.parser.ResourceTableParser.readPackage(ResourceTableParser.java:91)
at net.dongliu.apk.parser.parser.ResourceTableParser.parse(ResourceTableParser.java:60)
at net.dongliu.apk.parser.AbstractApkFile.parseResourceTable(AbstractApkFile.java:391)
at net.dongliu.apk.parser.AbstractApkFile.parseManifest(AbstractApkFile.java:188)
at net.dongliu.apk.parser.AbstractApkFile.getApkMeta(AbstractApkFile.java:69)
at com.android.myapplication.MainActivity$onCreate$1.run(MainActivity.kt:31)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
So I tried to use try-catch, and found 2 other cases:
{com.google.android.permissioncontroller - /system/priv-app/GooglePermissionController/GooglePermissionController.apk
{com.google.android.networkstack - /system/priv-app/NetworkStack/NetworkStack.apk
If you need, attached here those APK files:
And the sample project to try it out:
hsiafan commented
Resource table a new chunk type 0x0204, it has not been documented nor appeared in android tool source code yet. So just skip this chunk type at this time, and a new version 2.6.8 should works now.
AndroidDeveloperLB commented
Where is it supposed to be documented?
And do you know what it is?
AndroidDeveloperLB commented
Seems fixed now.