Read less information about apk file with aapt tool

I am using aapt tool to read the contents of an apk file with

aapt d badging myapk.apk

      

But the result is too great. I just need the package name and version name. Any way to limit it?

Update: I got it to work with cmd window. Look like this:

aapt d badging myapk.apk | find "pack"

      

+3


source to share


5 answers


//try it

aapt d badging myapk.apk | grep 'pack'

      



its showing to me as

padmakumar@padmakumar-desktop:~$ aapt d badging ./Desktop/NhpAndroid_tablet_k4.apk  | grep 'pack'
package: name='com.ti.et.nspire.android' versionCode='1' versionName='1.0'

      

+11


source


Here's a trick that works like a charm for me. I am using Backtrack 5 r2; GNU bash version 4.1.5 (1) -release (i486-pc-linux-gnu)

Assuming the executable is. / aapt is in the same shell or script directory. If not just add the path to the executable or use the export aapt = "/ path / to / aapt" and use the variable path.

out = $ (./ aap dump badging GameCIH.apk | grep 'application-label:' | awk -F: 'match ($ 0, ":") {print substr ($ 0, RSTART + 1)}' | tr -d "'")

From tag-app: 'GameCIH' on apk

Only:

GameCIH

Last thing. If you want a package name or version name, do the following:



out = $ (./ aap dump badging GameCIH.apk | grep 'versionName =' | awk -F: 'match ($ 0, "versionName =") {print substr ($ 2, RSTART-8)}' | tr - d "'")

This will return for example:

versionName = 3.0.0

Just change the versionName values to whatever you need.

Change RSTART-8 to something like this: RSTART + 4 and it will return:

3.0.0

Hope this helps!

+5


source


aapt d badging myapk.apk | grep package

      

for Windows, download UnxUtils to get grep command and more Linux:    http://unxutils.sourceforge.net/UnxUtils.zip

+2


source


aapt d badging myapk.apk | awk '/package/ {print($2)}' | awk '{print(mstr[split($1, mstr, \"=\")])}' | tr -d \"'\"

      

+1


source


Here's the Bash function:

# Display package name and version of APK file(s)
apk(){
    (
        set -o pipefail

        for path in "$@"; do
            aapt dump badging "$path" \
            | awk $'
                BEGIN {
                    p=""
                    v=""
                }

                match($0, /^package: name=\'([^\']*)\'/, a) {
                    p=a[1]
                }

                match($0, /versionName=\'([^\']*)\'/, b) {
                    v=b[1]
                }

                END {
                    if (length(p) && length(v)) {
                        print p, v
                    }
                }'
        done
    )
}

      

0


source







All Articles