1

I saw here that the command

aapt dump badging foo.apk

prints all the details of the specified package.

Is it possible to print any one property, say sdkversion? Something like

aapt dump badging -sdkversion foo.apk

P.S I'm using command prompt in windows.

EDIT

I am trying to store the package name in a variable. As of now, I have this code

@echo off
for /f "delims=" %%a in ('aapt dump badging foo.apk') do (
     REM each line of the output
)

I am able to retrieve each line of the output. Now I have to extract the package name from the string. For instance the first line is

package: name='com.timeplusq.noob' versionCode='15' versionName='1.5'

which is retrieved in the first iteration of the for loop. How do I extract the package name from it. I thought string manipulation would be straight forward, it is not. So how do I extract the package name from the string?

Community
  • 1
  • 1
SatheeshJM
  • 3,575
  • 8
  • 37
  • 60

1 Answers1

1

If you're on a Unix system or having cygwin on Windows, you could try this command :

aapt dump badging foo.apk | grep sdkVersion | sed -E "s/^[^:]+:\'(.*)\'$/\1/"

the regexp will extract the value of the line selected by grep command

EDIT :

In a Windows system, you can use the following script saved as a .cmd :

@echo off
set property=sdkVersion:'10'
set property=%property:sdkVersion=%
set property=%property:~2,-1%

echo.%property%
DayS
  • 1,561
  • 11
  • 15