A NodeJs + Shell Script Setup.
It Extracts top n
assets packed in apk (By size).
Create a Html Report.
- Install
top-assets
npm package
npm install -g top-assets
-
Run `npm install``
-
Prepare your Shell Enviroment, Save this in a
extract.sh
file and its path in~/.bash_profile
# run sh extract.sh
SourceDir=".";
DestDir="release-res";
ext_list=(".jpg" ".png" ".webp" ".jpeg")
mv *.apk app.zip
unzip app.zip -d app
mkdir release-res
rm -r report
mkdir report
mkdir report/assets
touch report/index.html
# Copy files, allowing duplicates with appended index
for i in "${ext_list[@]}"
do
echo "Searching for type: $i"
find ${SourceDir}/ -type f -regex ".*"$i"" |
while read x
do
bn=`basename $x`;
if [ -f "${DestDir}/$bn" ]
then
for i in {1..9999}
do
if [ ! -f "${DestDir}/${bn%.*}_${i}.${bn##*.}" ]
then
bn="${bn%.*}_${i}.${bn##*.}"
echo "$bn";
break;
fi
done
fi
cp "$x" "${DestDir}/$bn";
done
done
echo 'Sorting assets...'
# Run the module `top-assets` to filter top assets.
# Arguement: Count of Top Assets we want in the report
top-assets 25
# Cleanup
echo "Cleanup"
rm -r release-res
rm -r app
rm app.zip
For easy setup,
- Create a separate directory.
- Paste the apk which you want to run this tool on
- Run
sh extract.sh
in terminal. - It will generate a
/reports/index.html
- Open this report file, you will see top
n
assets listed along with its RAM Impact, Dimenstion, Name and Preview.
Note: This tool is already integrated on TeamCity as a Separate Build Config. You can optionally trigger any build and get the report generated.