5

How can I get the versionCode, versionName, application icon and application label from an APK with PHP

Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236
  • 1
    http://stackoverflow.com/questions/2097813/how-to-parse-the-androidmanifest-xml-file-inside-an-apk-package. this might help – blessanm86 Sep 26 '11 at 08:51

4 Answers4

5

I'm not that familiar with php so I can't provide any code, but the idea is:

  • unzip the APK file (since it's "nomal" zip format)
  • open the AndroidManifest.xml and
  • parse the <manifest> tag for android:versionCode and android:versionName
DonGru
  • 13,532
  • 8
  • 45
  • 55
  • How to deal with the references, such as the reference to the values in the `Strings.xml` file. – twlkyao Jan 07 '14 at 12:35
2

If I'm not wrong, APKs are simply zip files. And android packages will have some sort of XML file that will mention the version information.

In PHP, you can unzip as well as read XMLs.

jrharshath
  • 25,975
  • 33
  • 97
  • 127
1

Well,

It is correct that the apk is in fact a zip-file and that is easy to unzip. However the manifest xml is not in standard xml format. It is some kind of propitiatory Android format.

You can use apktool to unpack the xml, but it is in Java and not very fun if you don't have Java on the server.

There is also a Python Library available, AXMLParsePY

Then we have AXmlPrinter2, also written in Java

I am myself looking for a PHP library and have given up. Now looking for something lightweight I can convert from some other language.

j0k
  • 22,600
  • 28
  • 79
  • 90
www.jensolsson.se
  • 3,023
  • 2
  • 35
  • 65
1

As you might know an APK is a simple zip formated archive with it's metadata in XML format.

Try and unzip some apks and see which files have the information you need.

This can all be easily done in PHP.

the JinX
  • 1,950
  • 1
  • 18
  • 23