1、添加依赖
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.10</version>
</dependency>
2、读取apk的应用名称、包名、版本号、图标、大小等信息
public static void main(String[] args) {
try {
File file = new File("D://1.APK");
if (file.exists() && file.isFile()) {
ApkFile apkFile = new ApkFile(file);
ApkMeta apkMeta = apkFile.getApkMeta();
System.out.println("应用名称 :" + apkMeta.getLabel());
System.out.println("包名 :" + apkMeta.getPackageName());
System.out.println("版本号 :" + apkMeta.getVersionName());
System.out.println("图标 :" + apkMeta.getIcon());
System.out.println("大小 :" + (double) (file.length() * 100 / 1024 / 1024) / 100 + " MB");
//注释:apk所有信息都在apkMeta类里面。可以输出整个apkMeta来查看跟多详情信息
}
} catch (Exception e) {
e.printStackTrace();
}
}
3、输出结果
![魏本全的博客](https://img-blog.csdnimg.cn/20200623150600229.png)