14

I know that .apk files are zip files and when we extract them can parse manifest file inorder to finding some information about the app. It is very useful for someone like me that is going to create an app-store. Actually at least I can find the version name and version code of the app.

But in the android-studio when we build a signed apk the version name and version code is not defining in the manifest file. We should define them in the build.gradle file. So now in my app-store when users upload the files how can I find the version code and version name and detect that is not same with old versions?

2
  • Can you explain more why you want to do this? Commented Jul 27, 2014 at 6:23
  • @Code-Apprentice as I said, I have a app-store. I want when user upload the apk file I can find the version code and version name and be sure that these is not same with the old apks they have uploaded before. Commented Jul 27, 2014 at 6:25

2 Answers 2

40

Just use AAPT from your path/to/your/android-sdk/build-tools/your-api-version-available/...

An example of the command execution:

aapt dump badging theuserapp.apk 

And it will respond with something like:

package: name='com.blabla.theuserapp' versionCode='2000' versionName='2.0.0' 

Of course, as the tool is an executable which produces a raw text output you can easily script it and parse from your favorite scripting languaje.

Sign up to request clarification or add additional context in comments.

5 Comments

What programming language did you use to code your server apps? Every language as PHP,Python,Java, even Linux shell or Microsoft Powershell are good options to do this.
Cool thanks this helped me identify the version code for youtube player since I need to check it to prevent older versions from launching an embedded player.
It might be helpful to know that on a Mac with Android Studio, your tools are likely in ~/Library/Android/sdk/build-tools/<23.0.1>/aapt, where 23.0.1 is a version number that will change as you update your API targets.
@MartinRevert.. i am able to see manifest after executing this command. I got to know that it is showing sdkversion instead of minimumsdkversion. Is that fine?
@GvSharma Yes, sdkversion represents minimumsdkversion, But be careful, manifest can be overwritten by Gradle app config.
-3

On GNU/Linux environment you can make a bash search.

with these steps: -> on Studio choose terminal tab; -> change directory to root directory of your project. -> run this command $ find pwd -name *.apk -> yours apk files will be listed on the screen, then you can see the directory where they are hosted

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.