I'm building an Android APK inspector/extractor and ran into a strange issue with debug APKs.

My normal workflow is:

  1. Build a debug APK in Android Studio.
  2. Install it on my phone using adb install.
  3. After testing, I can pull the installed APK with: adb pull /data/app/.../base.apk
  4. I send that pulled APK to friends through WhatsApp.
  5. They can download it and install it normally through Android's GUI package installer.

I'm now testing an APK extractor I built. It reads the installed app's ApplicationInfo.sourceDir and copies the APK bytes to a user-selected location using a normal FileInputStream → SAF OutputStream.

The strange part:

  1. Install the same debug APK normally with adb install.
  2. My extractor extracts the installed base.apk.
  3. I send the extracted APK through WhatsApp.
  4. On the phone, tapping the APK gives: "App not installed as package appears to be invalid."
  5. But: adb install -t extracted.apk successfully installs it.

I initially suspected my extractor was modifying/corrupting the APK, but I compared the extracted APK with the APK I pulled using adb pull:

sha256sum Miau_non.apk Miau_base_debug.apk 9af34f5180dba1a24dfe24feb90bcd3953eb765ef3613effb18f1803acb512f6 Miau_non.apk 9af34f5180dba1a24dfe24feb90bcd3953eb765ef3613effb18f1803acb512f6 Miau_base_debug.apk 

So they are byte-for-byte identical.

What's even more interesting is that if I extract a release build using my extractor, the extracted APK installs normally through the GUI installer.

So my questions are:

  • Why would the GUI package installer reject the extracted debug APK when adb install -t accepts it?
  • Why does the APK pulled directly with adb pull appear to install normally, despite being byte-identical to the extractor's output?
  • Is there some installation/package-manager state or context involved that isn't represented in the APK bytes?
  • Is there something special about how Android handles testOnly debug APKs that could explain this behavior?

I'm on Android 16. The APKs are single-APK installs (no split APKs involved).

I'm specifically trying to understand the Android behavior rather than modify the APK, because an APK extractor should ideally preserve the APK exactly as installed.

submitted by /u/Minute_Mood_6396
[link] [comments]