How to read content of apk file programmatically?

android, android-sdk-tools, apk, dex, java

Solution

See this answer on another question: https://stackoverflow.com/a/34850406/55940

Basically you can use this:

PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(file.getAbsolutePath(), 0);

This would only get the meta data though... You would have to use a ZipInputStream etc to read the content of the file.

Problem

I need read the content of `apk` file (including `AndroidManifest.xml`) programmatically. I know there are some tools like `apktool`, `dex2jar`, `aapt` to extract apk content but, I need to do the same through an Android application. By the way my start point is a valid apk file path.

Original source

Related problems