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?

1 Answer 1

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%
4
  • ah no! I'm just using command prompt in windows.. any solutions for that?
    – SatheeshJM
    Sep 14, 2012 at 14:53
  • Er. I've never used batch scripts, so I'm a bit confused. I have updated the question. Can you please answer that? Thanks! :)
    – SatheeshJM
    Sep 14, 2012 at 19:06
  • Well, I tried to write a full script but I don't know enough about DOS scripting to do that... What about a simple Java application to do the job ?
    – DayS
    Sep 14, 2012 at 20:03
  • This is not helping on windows!
    – Prachi
    Aug 11, 2014 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.