| 1 |
# ArscBlamer |
| 2 |
ArscBlamer is a command-line tool that can parse an Android app's resources.arsc file and extract useful, actionable information about its contents. |
| 3 |
|
| 4 |
Features include: |
| 5 |
- Output all resource configurations and see type, variants, size, null entries, entry count, density, and (optionally) the resource names in that configuration. |
| 6 |
- Output all resource names in resources.arsc and see their private, shared, and proportional sizes as well as the configurations they belong to. |
| 7 |
- Output resources which are "baseless" (have no default value). |
| 8 |
|
| 9 |
### Usage |
| 10 |
##### Output resource configurations with resource names |
| 11 |
`$ bazel run //java/com/google/devrel/gmscore/tools/apk/arsc:ArscDumper -- --apk=/foo/bar.apk --keys > output.csv` |
| 12 |
##### Output all resource entries |
| 13 |
`$ bazel run //java/com/google/devrel/gmscore/tools/apk/arsc:ArscDumper -- --apk=/foo/bar.apk --type=entries > output.csv` |
| 14 |
##### Output all resource entries for resources that have no default configuration |
| 15 |
`$ bazel run //java/com/google/devrel/gmscore/tools/apk/arsc:ArscDumper -- --apk=/foo/bar.apk --type=baseless_keys > output.csv` |
| 16 |
|
| 17 |
**NB:** Relative file paths for the APK will not work with `bazel run`. To use relative file paths, see the **Building** section. |
| 18 |
|
| 19 |
### Building |
| 20 |
To use ArscBlamer with relative file paths, build the jar with: |
| 21 |
|
| 22 |
`$ bazel build //java/com/google/devrel/gmscore/tools/apk/arsc:ArscDumper_deploy.jar` |
| 23 |
|
| 24 |
### Understanding the output |
| 25 |
##### -\-type=configs |
| 26 |
- **Type:** The type of resource configuration (string, attr, id, ...). Different types have different numbers of entries in their entry list. |
| 27 |
- **Config:** The qualifier variants such as `en`, `v21`, `sw600dp`. See [here](http://developer.android.com/guide/topics/resources/providing-resources.html) for a full list. |
| 28 |
- **Size:** The total size of the resource configuration in bytes. This does not include the size of referenced resources, such as strings. |
| 29 |
- **Null Entries:** The number of entries in this resource configuration that are empty. The more there are, the more bytes you can save by removing the configuration. |
| 30 |
- **Entry Count:** The number of actual entries in this configuration. A configuration exists only if it has >= 1 Entry Count. Less usually means the configuration is easier to remove. |
| 31 |
- **Density:** A value from 0 to 1 representing the percent of entries in this configuration that are non-null. (e.g. 0.12 means 12% actual entries and 88% null entries). Lower means the configuration is more wasteful. |
| 32 |
- **Keys:** The resource names in this configuration. These are what need to be removed if you want to remove the configuration. Requires --keys. |
| 33 |
|
| 34 |
##### -\-type=entries or -\-type=baseless_keys |
| 35 |
- **Type:** The type of resource configuration (string, attr, id, ...). Different types have different numbers of entries in their entry list. |
| 36 |
- **Name:** The resource entry's name. |
| 37 |
- **Private Size:** The number of bytes that this entry is holding on to. This is how many bytes in resources.arsc will be saved if the entry is removed. |
| 38 |
- **Shared Size:** The number of bytes that this entry references which are also referenced from other entries. |
| 39 |
- **Proportional Size:** The total size, proportionally, that this entry is responsible for. These values should sum up to roughly the size of `resources.arsc`. |
| 40 |
- **Config Count:** The number of configurations this entry is referenced in. Entries, such as strings, which have a **Config Count** of 1 may be a candidate for removal. |
| 41 |
- **Configs:** The configurations this resource appears in. |
| 42 |
|
| 43 |
### Helpful tips on parsing a CSV with [Google Sheets](http://docs.google.com/spreadsheets) |
| 44 |
- Click on the filter button to get sortable columns. |
| 45 |
- Click on the Explore button in the bottom-right to get some neat metrics. |
| 46 |
|
| 47 |
|
| 48 |
# License |
| 49 |
|
| 50 |
``` |
| 51 |
Copyright 2016 Google Inc. All Rights Reserved. |
| 52 |
|
| 53 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 54 |
you may not use this file except in compliance with the License. |
| 55 |
You may obtain a copy of the License at |
| 56 |
|
| 57 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 58 |
|
| 59 |
Unless required by applicable law or agreed to in writing, software |
| 60 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 61 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 62 |
See the License for the specific language governing permissions and |
| 63 |
limitations under the License. |
| 64 |
``` |
| 65 |
|
| 66 |
# Disclaimer |
| 67 |
|
| 68 |
This is not an official Google product |