Get apk file information with aapt tool
来源:互联网 发布:北航软件学院考研 编辑:程序博客网 时间:2024/05/30 23:27
# -*- coding: utf-8 -*-
#python
'''
Created on 2014-1-15
@author: jhua50x
This script is for get apk information with aapt tool
'''
import sys
import os
import glob
import time
AAPT_COMMAND='.\\aapt\\aapt d badging'
APK_FOLDER='E:\WW03\googleplay'
APK_INFO_FILE='output.csv'
TEMP='temp.txt'
INFO = "[INFO]: " #print info lab
ERROR = "**ERROR**: " #print error info lab
DEBUG = "[DEBUG]: " #print debug info lab
if __name__ == "__main__":
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
print INFO + "Start get package from \"" + APK_FOLDER + "\\*.apk\""
#Get apk file list
file_list = glob.glob(APK_FOLDER + "\\*.apk")
#all apk information will store in APK_INFO_FILE
info_store = open(APK_INFO_FILE, 'w')
#info_store.write(time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) + '\n')
info_store.write('APK Name, APP ID, App Version, App Type\n')
print('APK Name, APP ID, App Version, App Type')
for file_path in file_list:
apk_name = file_path.split('\\')[-1]
#run aapt d badging apkfile and store the output in temp file
command_output = os.system(AAPT_COMMAND + ' ' + file_path + ' >' + TEMP)
#analysis the output, get apk version
temp_file = open(TEMP, 'r')
app_id = ''
app_version = ''
app_type = ''
for line in temp_file:
#get app_id and app_version from package line
if(line.split(':')[0] == 'package'):
app_id = line.split(' ')[1].split('=')[1]
app_id = app_id[1:-1]
app_version = line.split(' ')[3].split('=')[1]
app_version = app_version[:-2]
continue
if((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(Both)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') == -1)):
app_type = 'NDK(ARM)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') == -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(IA)'
else:
app_type = 'Dalvik'
print (apk_name + ',' + app_id + ',' + app_version + ',' + app_type)
info_store.write(apk_name + ',' + app_id + ',' + app_version + ',' + app_type + '\n')
temp_file.close()
info_store.close()
#python
'''
Created on 2014-1-15
@author: jhua50x
This script is for get apk information with aapt tool
'''
import sys
import os
import glob
import time
AAPT_COMMAND='.\\aapt\\aapt d badging'
APK_FOLDER='E:\WW03\googleplay'
APK_INFO_FILE='output.csv'
TEMP='temp.txt'
INFO = "[INFO]: " #print info lab
ERROR = "**ERROR**: " #print error info lab
DEBUG = "[DEBUG]: " #print debug info lab
if __name__ == "__main__":
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
print INFO + "Start get package from \"" + APK_FOLDER + "\\*.apk\""
#Get apk file list
file_list = glob.glob(APK_FOLDER + "\\*.apk")
#all apk information will store in APK_INFO_FILE
info_store = open(APK_INFO_FILE, 'w')
#info_store.write(time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) + '\n')
info_store.write('APK Name, APP ID, App Version, App Type\n')
print('APK Name, APP ID, App Version, App Type')
for file_path in file_list:
apk_name = file_path.split('\\')[-1]
#run aapt d badging apkfile and store the output in temp file
command_output = os.system(AAPT_COMMAND + ' ' + file_path + ' >' + TEMP)
#analysis the output, get apk version
temp_file = open(TEMP, 'r')
app_id = ''
app_version = ''
app_type = ''
for line in temp_file:
#get app_id and app_version from package line
if(line.split(':')[0] == 'package'):
app_id = line.split(' ')[1].split('=')[1]
app_id = app_id[1:-1]
app_version = line.split(' ')[3].split('=')[1]
app_version = app_version[:-2]
continue
if((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(Both)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') == -1)):
app_type = 'NDK(ARM)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') == -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(IA)'
else:
app_type = 'Dalvik'
print (apk_name + ',' + app_id + ',' + app_version + ',' + app_type)
info_store.write(apk_name + ',' + app_id + ',' + app_version + ',' + app_type + '\n')
temp_file.close()
info_store.close()
0 0
- Get apk file information with aapt tool
- aapt tool
- Get some information of the file
- Cannot run program "aapt": error=2. No such file or directory Fail to run aapt on *.apk apk instal
- Get file Hash with Qt
- [android tool]aapt的常用命令
- Debugging Smali code with apk-tool and NetBeans works!
- 分析apk -- aapt
- aapt解析apk包
- aapt批量修改apk
- aapt查看apk版本
- Get Browser and Operating System Information with PHP
- no compile tool is associated with the file extention 错误
- VC6.0 no compile tool is associated with the file
- 使用aapt解析apk信息报错“cannot execute binary file”
- get an image file with XMLHttpRequest and encode with base64
- 利用aapt解析apk文件
- Java 调用 aapt 解析 Apk
- Java SE 6 新特性系列
- 自定义preference onBindView易犯的错误
- 【其他】Windows Media Services 无法启动
- Ubuntu装好后因为“初始化月份字符串出错”无法启动libreoffice --中文版本
- configure: error: Subversion requires SQLite,Linux安装Subversion的各类问题
- Get apk file information with aapt tool
- linux 禁用selinux
- 健康APP在2014年的发展潜力
- SpringMVC配置文件全解
- (1)初始Hive —— 深入浅出学Hive
- 多个Icon的APk——实现多程序入口总结
- 史上最全的java随机数生成算法(转)
- 进程控制常用函数
- 正则表达式语法大全