- What is aapt tool in android
- DESCRIPTION
- OPTIONS
- Smaller PNGs, and Android’s AAPT tool
- But what if I want more than that?
- HUGE WARNING
- Android aapt
- Contents
- Where it is
- Usage
- Notes on commands and package contents
- badging
- permissions
- resources
- configurations
- xmltree
- Smaller PNGs, and Android’s AAPT tool
- But what if I want more than that?
- HUGE WARNING
- Что такое AAPT (Android Asset Packaging Tool) и как он работает?
- ОТВЕТЫ
- Ответ 1
- Ответ 2
- Ответ 3
What is aapt tool in android
List contents of Zip-compatible archive.
aapt d[ump] [—values] WHAT file.
strings Print the contents of the resource table string pool in the APK.
badging Print the label and icon for the app declared in APK.
permissions Print the permissions from the APK.
resources Print the resource table from the APK.
configurations Print the configurations in the APK.
xmltree Print the compiled xmls in the given assets.
xmlstrings Print the strings of the given compiled xml assets.
aapt p[ackage] [-d] [-f] [-m] [-u] [-v] [-x] [-z] [-M AndroidManifest.xml]
[-0 extension [-0 extension . ]] [-g tolerance] [-j jarfile]
[—debug-mode] [—min-sdk-version VAL] [—target-sdk-version VAL]
[—app-version VAL] [—app-version-name TEXT] [—custom-package VAL]
[—rename-manifest-package PACKAGE]
[—rename-instrumentation-target-package PACKAGE]
[—utf16] [—auto-add-overlay]
[—max-res-version VAL]
[-I base-package [-I base-package . ]]
[-A asset-source-dir] [-G class-list-file] [-P public-definitions-file]
[-S resource-sources [-S resource-sources . ]]
[-F apk-file] [-J R-file-dir]
[—product product1,product2. ]
[-c CONFIGS] [—preferred-configurations CONFIGS]
[raw-files-dir [raw-files-dir] . ]
[—output-text-symbols DIR]
Package the android resources. It will read assets and resources that are
supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R
options control which files are output.
aapt r[emove] [-v] file.
Delete specified files from Zip-compatible archive.
aapt a[dd] [-v] file.
Add specified files to Zip-compatible archive.
aapt c[runch] [-v] -S resource-sources . -C output-folder .
Do PNG preprocessing on one or several resource folders
and store the results in the output folder.
aapt s[ingleCrunch] [-v] -i input-file -o outputfile
Do PNG preprocessing on a single file.
aapt v[ersion]
Print program version.
DESCRIPTION
OPTIONS
If you put the special locale, zz_ZZ on the list, it will perform pseudolocalization on the default locale, modifying all of the strings so you can look for strings that missed the internationalization process. For example:
port,land,zz_ZZ
Источник
Smaller PNGs, and Android’s AAPT tool
Apr 20, 2016 · 3 min read
Great question Dan. I hope that you were contemplating this while you took your profile picture 😉
And yes, it’s true, the android toolchain does in fact run some PNG optimization. Check out the official docs:
Image resources placed in res/drawable/ may be automatically opt i mized with lossless image compression by the aapt tool during the build process. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This will result in an image of equal quality but which requires less memory. So be aware that the image binaries placed in this directory can change during the build.
Hmm.. so that’s nice.. Images with really does. Tracking down the analyze_image function inside of png.cpp we can see that it checks for three specific optimizations:
1. Every pixel has R == G == B (grayscale)
2. Every pixel has A == 255 (opaque)
3. There are no more than 256 distinct RGBA colors
So AAPT will load your PNG, test if it can convert it to grayscale, test if it’s fully opaque, or test if it can be converted to an indexed variant. That’s it.
These checks make a lot of sense when you consider the fact that most of the PNG assets inside of an APK typically are either grayscale, opaque, or limited in color uniqueness; Having the ability to take these known formats, and convert them to smaller PNG files, seems like a good deal.
But what if I want more than that?
Probably more interesting, is all the stuff that AAPT doesn’t do; which includes anything that A) will alter the visual perception of your image (potentially making it lower quality) and B) anything more advanced than color mode swapping.
This is the exact reason I discuss using more advanced tools in my previous article. Applying these to your pipeline can help reduce PNG file size in a way that the standard AAPT tool can’t.
HUGE WARNING
It’s important to remember that with the modern data compression algorithms, recursive data compression isn’t possible. If you take a piece of data that you’ve compressed, and try to compress it again, you’ll usually end up making it larger and at best, just keep it the same size.
So, if you’ve applied an optimization process to PNGs, prior to them being tossed to AAPT, they may end up getting inflated, sometimes by 10+%. Which seems like a raw deal: If you’ve taken all this time to shrink your PNG files, they shouldn’t get inflated later :\
The solution to this issue is using the cruncherEnabled flag in your Gradle files to disable this process for PNG files:
aaptOptions <
cruncherEnabled = false
>
This will turn off the AAPT png optimization for non-9patch PNG files inside of your APK (I haven’t figured out what it does with 9Patches yet…)
The result, is that you can use your own custom PNG optimizer scripts, shrinking them as small as possible, and know that the AAPT tool won’t accidentally inflate them later.
Источник
Android aapt
aapt stands for Android Asset Packaging Tool. This tool is part of the SDK (and build system) and allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.
Build scripts and IDE plugins utilize this tool to package the apk file that constitutes an Android application.
Contents
Where it is
In the SDK, aapt is found in the $ANDROID_HOME/platforms/$SDK/tools/ directory of the SDK (where $SDK is the name of some Android version, like android-2.1).
In the Android open source build environment, aapt is found in $ANDROID_BUILD_HOME/out/host/linux-x86/bin
Usage
If you execute appt without any parameters it will show you some usage help.
Direct from an eclair version of aapt (aapt version 0.2):
Notes on commands and package contents
Note that an Android package is just a collection of files inside a pkzip’ed archive.
The contents below show results using aapt on the «SpareParts.apk» package from an eclair build of Android. This package is relatively small, so it is useful for showing complete listings.
The ‘list’ command shows the contents of the package.
- the -v option shows the contents of the zipped archive, and is just like ‘unzip -l -v’
For comparison, here is the output of ‘unzip -l -v’
- the -a option shows all the resources and also parses out the xmltree from the AndroidManifest.xml file.
This is similar to doing the following three commands in sequence: aapt list
; aapt dump resources
; aapt dump xmltree
The ‘dump’ sub-command of aapt is used to display the values of individual elements or parts of a package.
badging
permissions
resources
configurations
xmltree
The xmltree option with the ‘dump’ command allows you to print out the xml parse tree for an xml file contained within the package.
Источник
Smaller PNGs, and Android’s AAPT tool
Apr 20, 2016 · 3 min read
Great question Dan. I hope that you were contemplating this while you took your profile picture 😉
And yes, it’s true, the android toolchain does in fact run some PNG optimization. Check out the official docs:
Image resources placed in res/drawable/ may be automatically opt i mized with lossless image compression by the aapt tool during the build process. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This will result in an image of equal quality but which requires less memory. So be aware that the image binaries placed in this directory can change during the build.
Hmm.. so that’s nice.. Images with really does. Tracking down the analyze_image function inside of png.cpp we can see that it checks for three specific optimizations:
1. Every pixel has R == G == B (grayscale)
2. Every pixel has A == 255 (opaque)
3. There are no more than 256 distinct RGBA colors
So AAPT will load your PNG, test if it can convert it to grayscale, test if it’s fully opaque, or test if it can be converted to an indexed variant. That’s it.
These checks make a lot of sense when you consider the fact that most of the PNG assets inside of an APK typically are either grayscale, opaque, or limited in color uniqueness; Having the ability to take these known formats, and convert them to smaller PNG files, seems like a good deal.
But what if I want more than that?
Probably more interesting, is all the stuff that AAPT doesn’t do; which includes anything that A) will alter the visual perception of your image (potentially making it lower quality) and B) anything more advanced than color mode swapping.
This is the exact reason I discuss using more advanced tools in my previous article. Applying these to your pipeline can help reduce PNG file size in a way that the standard AAPT tool can’t.
HUGE WARNING
It’s important to remember that with the modern data compression algorithms, recursive data compression isn’t possible. If you take a piece of data that you’ve compressed, and try to compress it again, you’ll usually end up making it larger and at best, just keep it the same size.
So, if you’ve applied an optimization process to PNGs, prior to them being tossed to AAPT, they may end up getting inflated, sometimes by 10+%. Which seems like a raw deal: If you’ve taken all this time to shrink your PNG files, they shouldn’t get inflated later :\
The solution to this issue is using the cruncherEnabled flag in your Gradle files to disable this process for PNG files:
aaptOptions <
cruncherEnabled = false
>
This will turn off the AAPT png optimization for non-9patch PNG files inside of your APK (I haven’t figured out what it does with 9Patches yet…)
The result, is that you can use your own custom PNG optimizer scripts, shrinking them as small as possible, and know that the AAPT tool won’t accidentally inflate them later.
Источник
Что такое AAPT (Android Asset Packaging Tool) и как он работает?
Что означает AAPT (Android Asset Packaging Tool)? Как это работает?
Можно ли отправить файл .so одного приложения в файл APK другого приложения с помощью AAPT?
ОТВЕТЫ
Ответ 1
AAPT позволяет просматривать, создавать и обновлять ZIP-совместимые архивы (ZIP, JAR и APK). Он также может компилировать ресурсы в бинарные активы. Это базовый конструктор для приложений Android.
Конечно, вы можете отправлять .so файлы из приложения, но если вы хотите использовать его, вам понадобятся плагины для обратного инжиниринга, и они не очень рекомендуются из-за сложности. Я не знаю никого для Android, но есть множество плагинов окружения.
Также вы можете исследовать немного перед публикацией,
Ответ 2
Это стандартный инструмент Android SDK для упаковки всех классов и ресурсов в файл APK.
Ответ 3
AAPT расшифровывается как Android Asset Packaging Tool. Android Asset Packaging Tool (aapt) берет файлы ресурсов вашего приложения, такие как файл AndroidManifest.xml и файлы XML для ваших действий, и компилирует их. Это отличный инструмент, который поможет вам просматривать, создавать и обновлять ваши APK файлы. (а также файлы zip и jar). Он также может компилировать ресурсы в бинарные активы. Это базовый конструктор для приложений Android. Этот инструмент является частью SDK (и собирает фреймворк) и позволяет вам просматривать, создавать и перепроектировать Zip-perfect-хроники (zip, jolt, apk)
Вы можете найти это
aapt package , aapt add — Сборка приложений для Android (APK)
aapt dump — получение информации из файла APK с помощью:
Источник