• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

hsiafan/apk-parser: Apk parser for java

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

hsiafan/apk-parser

开源软件地址:

https://github.com/hsiafan/apk-parser

开源编程语言:

Java 100.0%

开源软件介绍:

APK parser lib, for decoding binary XML files, getting APK meta info.

Table of Contents

Features

  • Retrieve APK meta info, such as title, icon, package name, version, etc.
  • Parse and convert binary XML files to text
  • Get classes from DEX files
  • Get APK singer info

Get APK-parser

Get APK-parser from the Maven Central Reposotiry:

<dependency>
    <groupId>net.dongliu</groupId>
    <artifactId>apk-parser</artifactId>
    <version>2.6.10</version>
</dependency>

From version 2.0, apk-parser requires Java 7. The last version to support Java 6 is 1.7.4.

Usage

The ordinary way is using the ApkFile class, which contains convenient methods to get AndroidManifest.xml, APK info, etc. The ApkFile need to be closed when no longer used. There is also a ByteArrayApkFile class for reading APK files from byte array.

1. APK Info

ApkMeta contains name(label), packageName, version, SDK, used features, etc.

try (ApkFile apkFile = new ApkFile(new File(filePath))) {
    ApkMeta apkMeta = apkFile.getApkMeta();
    System.out.println(apkMeta.getLabel());
    System.out.println(apkMeta.getPackageName());
    System.out.println(apkMeta.getVersionCode());
    for (UseFeature feature : apkMeta.getUsesFeatures()) {
        System.out.println(feature.getName());
    }
}
2. Get Binary XML and Manifest XML Files
try (ApkFile apkFile = new ApkFile(new File(filePath))) {
    String manifestXml = apkFile.getManifestXml();
    String xml = apkFile.transBinaryXml("res/menu/main.xml");
}
3. Get DEX Classes
try(ApkFile apkFile = new ApkFile(new File(filePath))) {
    DexClass[] classes = apkFile.getDexClasses();
    for (DexClass dexClass : classes) {
        System.out.println(dexClass);
    }
}
4. Get APK Signing Info

Get the APK signer certificate info and other messages, using:

try(ApkFile apkFile = new ApkFile(new File(filePath))) {
    List<ApkSigner> signers = apkFile.getApkSingers(); // apk v1 signers
    List<ApkV2Signer> v2signers = apkFile.getApkV2Singers(); // apk v2 signers
}
5. Locales

An APK may have different info (title, icon, etc.) for different regions and languages——or we can call it a "locale". If a locale is not set, the default "en_US" locale (Locale.US) is used. You can set a preferred locale by:

try (ApkFile apkFile = new ApkFile(new File(filePath))) {
    apkFile.setPreferredLocale(Locale.SIMPLIFIED_CHINESE);
    ApkMeta apkMeta = apkFile.getApkMeta();
}

APK-parser will find the best matching languages for the locale you specified.

If locale is set to null, ApkFile will not translate the resource tag, and instead just give the resource ID. For example, the title will be something like '@string/app_name' instead of the real name.

Reporting Issues

If this parser has any problem with a specific APK, open a new issue, with a link to download the APK file.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
changmingxie/tcc-transaction: tcc-transaction是TCC型事务java实现发布时间:2022-06-24
下一篇:
briandilley/jsonrpc4j: JSON-RPC for Java发布时间:2022-06-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap