借助Android sdk提过的aapt工具获取apk包名和首activity
def get_packer_activity(addr): # 提过apk路径,获取包名和首页activity cmd = ‘aapt dump badging ‘+ addr+‘>abc.log‘ flag = [] if 0 == os.system(cmd): try: with open(‘abc.log‘, ‘r‘, encoding=‘UTF-8‘) as file: abc = file.readlines() for line in abc: if ‘launchable-activity‘ == line.strip()[:19] or ‘package: name‘ == line.strip()[:13]: flag.append(line.strip().split(‘\‘‘)[1]) except FileNotFoundError: print(‘未找到需要的文件‘) return flag print(get_packer_activity(‘C:\\Users\\Administrator\\Desktop\\AnTuTu.apk‘))