Extracting AndroidManifest.xml file from apk using just Java

10,340

If you look into the question on your comment link, there is an answer (Ribo's community wiki) providing a code snippet in Java to decode the manifest XML in the APK, and then recreate the XML.

Providing the APK file, the code then extracts the manifest and recreate it.

I just read the code very quickly, and I didn't find anything tied to Android (i.e., pure Java). So I believe you can copy that code and create a standalone Java jar to be executed on demand. Or integrated into code, in case you want go further.

Share:
10,340
Otra
Author by

Otra

Updated on June 04, 2022

Comments

  • Otra
    Otra almost 2 years

    Is there a way to retrieve the androidmanifest.xml using just Java? I know about android-apktools but I can't install an application. I need to keep this restricted to just Java and whatever libraries I point it to. Is there a library with these kind of functions (like an apktool.jar)?

    Thanks.

  • Otra
    Otra almost 13 years
    Great! I skipped that answer because it said it was meant to run on Android but if there isn't anything that ties it, then I'll give it a try!
  • davidcesarino
    davidcesarino almost 13 years
    Like I said, I didn't see any class that wouldn't be available in Java. The first snippet (the heavy work) is written basically with String, Integer and StringBuffer... and let me say, a very complex binary manipulation :-) . Same for JarFile and InputStream. I hope this all answers your question, and then I wish you good luck implementing it!
  • Otra
    Otra almost 13 years
    Yes! It worked perfectly (minor edits needed but it was standalone)!
  • davidcesarino
    davidcesarino almost 13 years
    Great. I actually starred this question because I think/suspect I might need this in the future.