Sunday, May 7, 2017

Minify static resources in an android application

Standard
Sometimes an android application includes lots of static resources like html, css, jss or json files, this leads to a significant increase in the apk size. We all want our android application apk on diet. In this post, I will share a way to reduce the size of static resources thus reducing the size of apk.

I will be using node.js and gulp to compress static files. This post uses the code from a previous post.

This gradle plugin will be used to integrate minification within the build process.

The process includes following steps:

  1. Update build.gradle 
  2. Put all the static resources in "static_src" under app folder. This path is configurable and can be changed in "minifyStaticResources" task

Following commands minify the static resources

./gradlew iG
 
cd app/gulp-task

npm install
./gradlew mSR
 

Fully working code is available here.

Hope this helps. Happy coding.
Thanks for printing this post. Hope you liked it.
Keep visiting and sharing.
Thanks,
Ashwani.

0 comments :

Post a Comment