How to rescue versionCode and versionName from an APK?

Asked

Viewed 91 times

1

In a given case, a certain company does not want its application to be posted on Google Play. However the idea would be to create a version control within the company’s own system to make the upload of .apk and save some basic information to a database table. This information would be an id, versionCode, versionName, URL of the address saved from .apk, and date of dispatch.

I would like to extract only the versionCode and the versionName of apk at the moment the upload is made, so that it is not necessary to type this manually at the time of the version registration.

How can I rescue the versionCode and the versionName from an APK?

  • Has in the AndroidManifest.xml, that crazy xml compiled from Android. I’ll see more details later

  • 1

    @Jeffersonquesado I think you did not understand the question very well. Hue

  • so, get this apk info, check? unzip on apk, read the compiled binary manifest. Wouldn’t that be it?

  • 1

    @Jeffersontaken that way anyway. The system receives an apk, interprets, rescues the version code and the version name (in Manifest - as you said) and returns the values.

  • 1

    I believe that only with some command line tools or with Java that a person suggested is it possible to decode Manifest. This answer may help: https://stackoverflow.com/questions/2097813/how-to-parse-the-androidmanifest-xml-file-inside--apk-package. I have seen apktool generate yaml with some interesting links.

  • @acklay then i understood xD I’ve needed to do this a few times, after I’m on a computer I see here if I can rediscover my steps.

  • @Wakim wanted to try using javascript or php, but not by command line. I found something in php, but returns only versionCode. I couldn’t adapt it to regale the versionName. Check it out: https://stackoverflow.com/a/16449148/2570426

  • I think using this same code from to extrapolate the versionName, because it’s right after versionCode, then just add some offset, based on versionCode also to get to the versionName. But then it’s the test basis to get the right amount.

Show 3 more comments

1 answer

0

I had to resolve this same situation recently. If, as in my case, your apk is on a PHP-supported server, you can use lib PHP APK PARSER to extract the AndroidManifest.xml and the class XMLReader PHP native to get the versionCode and versionName.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.