• Stars
    star
    637
  • Rank 70,628 (Top 2 %)
  • Language
    Java
  • License
    Other
  • Created about 9 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

APK parser for Android

APK Parser Maven Central Software License Twitter Follow

Features

  • Retrieve basic apk metas, such as title, icon, package name, version, etc.
  • Parse and convert binary xml file to text
  • Classes from dex file
  • Get certificate metas and verify apk signature

Get apk-parser

Download the latest AAR or grab via Gradle:

compile 'com.jaredrummler:apk-parser:1.0.2'

Usage

The easiest way is to use the ApkParser class, which contains convenient methods to get AndroidManifest.xml, apk meta infos, etc. #####1. Apk meta info ApkMeta contains name(label), packageName, version, sdk, used features, etc.

PackageManager pm = getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo("com.facebook.katana", 0);
ApkParser apkParser = ApkParser.create(appInfo);
ApkMeta meta = apkParser.getApkMeta();
String packageName = meta.packageName;
long versionCode = meta.versionCode;
List<UseFeature> usesFeatures = meta.usesFeatures;
List<String> requestedPermissions = meta.usesPermissions;

#####2. Get binary xml and manifest xml file

ApplicationInfo appInfo = getPackageManager().getApplicationInfo("some.package.name", 0);
ApkParser apkParser = ApkParser.create(appInfo);
String readableAndroidManifest = apkParser.getManifestXml();
String xml = apkParser.transBinaryXml("res/layout/activity_main.xml");

#####3. Get dex classes

ApplicationInfo appInfo = getPackageManager().getApplicationInfo("com.instagram.android", 0);
ApkParser apkParser = ApkParser.create(appInfo);
List<DexInfo> dexFiles = apkParser.getDexInfos(); // if size > 1 then app is using multidex
for (DexInfo dexInfo : dexFiles) {
  DexClass[] dexClasses = dexInfo.classes;
  DexHeader dexHeader = dexInfo.header;
}

#####4. Get certificate and verify apk signature

ApplicationInfo appInfo = getPackageManager().getApplicationInfo("com.instagram.android", 0);
ApkParser apkParser = ApkParser.create(appInfo);
if (apkParser.verifyApk() == ApkParser.ApkSignStatus.SIGNED) {
  System.out.println(apkParser.getCertificateMeta().signAlgorithm);
}

#####5. Get intent-filters from apk manifest:

ApkParser parser = ApkParser.create(getPackageManager(), "com.android.settings");
AndroidManifest androidManifest = parser.getAndroidManifest();
for (AndroidComponent component : androidManifest.getComponents()) {
  if (!component.intentFilters.isEmpty()) {
    for (IntentFilter intentFilter : component.intentFilters) {
      // Got an intent filter for activity/service/provider/receiver.
    }
  }
}

#####6. Locales Apk may return different infos(title, icon, etc.) for different region and language, which is determined by Locales. If the locale is not set, the "en_US" locale(Locale.US) is used. You can set the locale like this:

ApkParser apkParser = ApkParser.create(filePath);
apkParser.setPreferredLocale(Locale.SIMPLIFIED_CHINESE);
ApkMeta apkMeta = apkParser.getApkMeta();

The PreferredLocale parameter work for getApkMeta, getManifestXml, and other binary xmls. Apk parser will find best match languages with locale you specified.

If locale is set to null, ApkParser will not translate resource tag, just give the resource id. For example, apk title will be '@string/app_name' instead of 'WeChat'.


APK Parser is based on CaoQianLi's apk-parser

More Repositories

1

AnimatedSvgView

Animated SVG Drawing for Android
Java
1,975
star
2

AndroidProcesses

DEPRECATED
Java
1,804
star
3

Cyanea

A theme engine for Android
Kotlin
1,451
star
4

AndroidDeviceNames

A small Android library to get the market name of an Android device.
Java
1,385
star
5

MaterialSpinner

A spinner view for Android
Java
1,324
star
6

ColorPicker

A highly customizable color picker for Android
Java
792
star
7

KtSh

Execute shell commands on Android or the JVM
Kotlin
710
star
8

HtmlDsl

Build valid HTML for Android TextView
Kotlin
540
star
9

AndroidAnimations

A bunch of fun animations for Android.
Java
74
star
10

vector2svg

Convert Android VectorDrawable XML resource file to SVG
Java
67
star
11

android-shell-scripts

Shell scripts for Android
Shell
43
star
12

TrueTypeParser

TrueType Font Parser for Android
Java
38
star
13

FastScroll-RecyclerView

ReyclerView with fast scrolling and scroll popups
Java
35
star
14

TwoDScrollView

Java
20
star
15

snet-decompiled

SafetyNet Decompiled
Java
16
star
16

GooglePlayScraper

Simple web scraper to get app information from Google Play
Java
11
star
17

sfntly

A Library for Using, Editing, and Creating SFNT-based Fonts
Java
9
star
18

bootanimation-scripts

Shell
7
star
19

Movies

Simple movie app for Android
Java
7
star
20

Baking

Java
6
star
21

EasterEggs

Collection of easter eggs you can put in your app.
Java
5
star
22

BlockingDialog

Show a dialog from a background thread and wait for a result.
Java
3
star
23

SO-41872033

http://stackoverflow.com/questions/41872033/how-to-change-theme-from-another-app-resource-in-android
Java
2
star
24

UnixPermission

Unix permission parser written in Kotlin
Kotlin
2
star
25

now-wallpapers

44 Google Now Wallpapers
Java
2
star
26

java-code-styles

IntelliJ IDEA code style settings for Java and Android projects.
Shell
2
star
27

SimpleMvp

Java
1
star
28

github

This repository contains assets used in GitHub repo README.md files by GitHub user @jaredrummler
1
star
29

jaredrummler

1
star