如何使用AAPT转储时打印指定的参数 [英] how to print a specified parameter when using aapt dump

查看:237
本文介绍了如何使用AAPT转储时打印指定的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这里该命令

aapt dump badging foo.apk

打印指定包的所有细节。

prints all the details of the specified package.

是否可以打印任何一个属性,说sdkversion?
类似

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

aapt dump badging -sdkversion foo.apk

P.S我使用命令提示符窗口。

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

修改

我想包名称存储在一个变量。
截至目前,我有这个code

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

包:名称='com.timeplusq.noob'版本code = '15'=的versionName'1.5'

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?

推荐答案

如果您使用的是Windows在Unix系统或具有Cygwin的,你可以试试这个命令:

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/"

正则表达式将提取选定的行的值的grep 命令

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

编辑:

在Windows系统中,你可以使用保存为下面的脚本的.cmd

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%

这篇关于如何使用AAPT转储时打印指定的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆