• 1、失败现象:cmd执行ok,脚本中执行失败
  • 2、解决


1、失败现象:cmd执行ok,脚本中执行失败

本地命令行执行aapt 正常

~ ᐅ aapt2 dump badging /Users/xxxx/tencent.apk
package: name='com.tencent.xx' versionCode='116' versionName='1.16.0' platformBuildVersionName='10' platformBuildVersionCode='29' compileSdkVersion='29' compileSdkVersionCodename='10'
sdkVersion:'21'
targetSdkVersion:'28'

放到python脚本中执行失败

aapt2 dump badging /Users/xxxx/tencent.apk
[]
/bin/sh: aapt2: command not found

2、解决

aapt 路径在:

$ANDROID_HOME/build-tools/xx.x.x

复制aapt 到 platform-tools 目录下

$ANDROID_HOME/platform-tools