Over a million developers have joined DZone.

Use BinaryDrawable to Bundle Images into Android JAR Files

DZone's Guide to

Use BinaryDrawable to Bundle Images into Android JAR Files

· Java Zone
Free Resource

Never build auth again! The Okta Developer Platform makes it simple to implement authentication, authorization, MFA and more in Java applications. Get started with the free API.

Android developers interested in including images in their JAR files - at least those making limited use of images and hoping to avoid the trouble of a res folder or Android library project - might find BinaryDrawable, a new tool from Hipmob, to be useful. According to Hipmob, it works like this:

To convert any image that can be understood by the Android platform's built-in BitmapFactory into a BinaryDrawable instance we simply read the image file and create a Java source file that includes a byte array with the image data. The generated class can then use decodeByteArray to get a Bitmap, and then it is a short hop to a BitmapDrawable.

Be aware, though, that there are some serious limitations to this tool: only very small images will work (under about 10kb), and JPG and PNG are the only acceptable formats. So, BinaryDrawable isn't for everybody, but if you only need small images here and there - icons seem like the most likely use - it could be worth checking out.

Build and launch faster with Okta’s user management API. Register today for the free forever developer edition!


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}