ngr info
Prints what is inside an apk without unpacking it: the package, the version, the name and icon, the permissions, the resource table and the list of files. It is the command for looking at an apk before touching it. It reads the apk and writes nothing.
Usage
ngr info [options] <apk>
Inputs
| Input | What it is |
|---|---|
<apk> |
An apk file. Only one |
Options
Format and detail:
| Option | What it does | Default |
|---|---|---|
--format <text|json|xml> |
Report format | text |
-v, --verbose |
More detail: all configurations, all activities and the packages of the resource table |
What is printed. Each one asks for a part of the report:
| Option | What it does | Default |
|---|---|---|
--package |
The package name (the application id), from the manifest. With -v, also the packages of the resource table |
|
--version-code |
The application version code | |
--version-name |
The application version name | |
--min-sdk-version |
The minimum SDK version | |
--target-sdk-version |
The target SDK version | |
--app-name |
The application name. With -v, all configurations |
|
--app-icon |
The path or value of the icon. With -v, all configurations |
|
--app-round-icon |
The path or value of the round icon. With -v, all configurations |
|
--app-class |
The name of the Application class |
|
--activities |
The main activity. With -v, all declared activities |
|
--permissions |
The permissions it requests | |
--resources |
All the resources of the resource table | |
--filter-type <type> |
Limits --resources to one resource type. Can be repeated |
|
--strings |
The string pool of the resource table | |
--configurations |
All the configurations of the apk | |
--languages |
All the languages of the apk | |
--locales |
All the locales of the apk | |
--files |
The files inside the apk | |
--xml-files |
The compiled xml files inside the apk | |
-h, --help |
Shows the help |
What it writes
It writes no files. The report goes to stdout.
With no content option it prints the default set: package, VersionCode, VersionName, AppName,
AppIcon, application-class and activity-main.
package="com.example.app"
VersionCode="7"
VersionName="1.2.3"
AppName="Example"
AppIcon="res/mipmap-mdpi-v4/ic_launcher.png"
application-class=".App"
activity-main=".MainActivity"
Asking for a content option removes those defaults and prints only what you asked for. With --package --version-code those two lines come out and nothing else. Content options can be combined.
-v expands what is printed. With the default set it adds the packages of the resource table, all the
configurations of the name and the icon, the list of activities and the permissions. Next to a content option it
expands only that part: --activities -v prints the main activity and the list of the three declared ones.
activities [ count 3]
1) .MainActivity
2) .DetailActivity
3) .ShortcutAlias
Permissions come out like this:
uses-permission [ count 4]
1) android.permission.ACCESS_NETWORK_STATE
2) android.permission.INTERNET
3) android.permission.POST_NOTIFICATIONS
4) android.permission.READ_EXTERNAL_STORAGE
The lists (--files, --xml-files, --configurations, --languages, --locales) carry the number of elements
and each element numbered.
Resources
--resources prints each package, each type and each resource with its identifier:
Package name=com.example.app id=0x7f
type anim id=1 entryCount=1
resource 0x7f010000 anim/fade_in
type animator id=2 entryCount=1
resource 0x7f020000 animator/pulse
...
--filter-type keeps only the types you name, and can be repeated:
ngr info --resources --filter-type string --filter-type mipmap app.apk
With -v each resource also carries its value in each configuration:
Package name=com.example.app id=0x7f
type bool id=5 entryCount=2
resource 0x7f050000 bool/disabled
() false
resource 0x7f050001 bool/enabled
() true
(-mcc310-mnc4) false
(-sw600dp) false
--filter-type without --resources prints nothing.
Other formats
--format json and --format xml give the same structured report. In JSON it is a list with one object:
[
{
"package":"com.example.app",
"VersionCode":7,
"VersionName":"1.2.3",
"AppName":"Example",
"AppIcon":"res/mipmap-mdpi-v4/ic_launcher.png",
"application-class":".App",
"activity-main":".MainActivity"
}
]
And in XML:
<?xml version='1.0' encoding='utf-8' ?>
<info>
<package>com.example.app</package>
<VersionCode>7</VersionCode>
<VersionName>1.2.3</VersionName>
<AppName>Example</AppName>
<AppIcon>res/mipmap-mdpi-v4/ic_launcher.png</AppIcon>
<application-class>.App</application-class>
<activity-main>.MainActivity</activity-main>
</info>
Examples
See the default set:
ngr info app.apk
See only the permissions:
ngr info --permissions app.apk
Get the version name and version code for a script:
ngr info --format json --version-name --version-code app.apk
List the resources of type string:
ngr info --resources --filter-type string app.apk
See the files the apk contains:
ngr info --files app.apk
Exit codes
| Code | When |
|---|---|
| 0 | The report was printed. Also with a protected apk, which gives no report, and with an apk without resources.arsc |
| 1 | The apk does not exist, is not a readable zip or is a zip without AndroidManifest.xml (a .jar, for example) |
| 2 | The options are wrong: <apk> is missing, there is an extra input, --format has a value that is not valid |
Things to know
- A protected apk gives no report.
ngrcalls an apk protected when it has entries underclasses.dex/orAndroidManifest.xml/, as if those files were folders.infowrites a single line to stderr and ends with 0:
WARN: PROTECTED
- An apk without
resources.arschas no resource table.--resources,--stringsand the other options that read the table print nothing and end with 0. What the manifest stores as a reference to a resource comes out unresolved: in such an apk,AppNamecomes out as a hexadecimal reference.
AppName="@0x7f040000"
- With
--format jsonand no table, the report comes out empty: a JSON list without objects, not an error. - A
.jaris not an apk forinfo. It says'sample.jar' is a zip but not an apk (no AndroidManifest.xml).and ends with 1. - Resources and compiled xml have their own commands. To get a specific value use
ngr resource, and to see a compiled xml,ngr xml.
See also
ngr resource, to read specific resources.ngr xml, to read a compiled xml, such as the manifest.ngr identify, to find out what a file is before asking it for a report.- “Inspecting an apk”.