4

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
  • 8,108
  • 3
  • 34
  • 49
  • To clarify: I have seen this question [link](http://stackoverflow.com/questions/2097813/how-to-parse-the-androidmanifest-xml-file-inside-an-apk-package) but it was answered with apk-tools. I need to be able to do this using just Java. – Otra Jun 14 '11 at 13:41

1 Answers1

3

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.

Community
  • 1
  • 1
davidcesarino
  • 16,160
  • 16
  • 68
  • 109
  • 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! – Otra Jun 14 '11 at 14:04
  • 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! – davidcesarino Jun 14 '11 at 14:14
  • Yes! It worked perfectly (minor edits needed but it was standalone)! – Otra Jun 14 '11 at 14:19
  • Great. I actually starred this question because I think/suspect I might need this in the future. – davidcesarino Jun 14 '11 at 14:27