Skip to content

{ Category Archives } Uncategorized

3430 bytes, the smallest APK ever!

What is the absolute smallest size of a “Hello World” app that can be published on the market? It’s 3430 bytes, and the app is here for your enjoyment: https://play.google.com/store/apps/details?id=h.w Size Compressed Name 345 248 META-INF/MANIFEST.MF 466 314 META-INF/A.SF 446 363 META-INF/A.RSA 97 97 res/drawable/a.png 1300 489 AndroidManifest.xml 588 588 resources.arsc 820 463 classes.dex 4062 [...]

The smallest Android license check

We all know the License Verification Library a.k.a. Google LVL. It is a bunch of code witch does the IPC call to the Market, verifies the signature of the answer, interprets the result according to policies, stores the result encrypted on storage, etc. LVL has 20+ classes/interfaces and 2000 lines of code. It is also [...]

Android: obfuscating the JNI surface layer

Proguard is a popular Java obfuscator. It makes the compiled bytecode (either JVM or Dalvik) harder to understand when decompiled (obfuscation), and also smaller by class/method renaming and optimization. There are two aspects of the Java source that are not affected by Proguard. One are the classes that interface with Android, basically the Activities, Views, [...]

Crude native code protection on Android

Any application code (APK) that is published becomes exposed to decompilation. Obfuscating the Java code (e.g. with Proguard) makes the Java decompilation harder. But the Proguard obfuscation does not affect the native code (NDK, JNI) of the application in any way. What’s more, the JNI access points to the native library are clearly visible with [...]

static: the Android application package

The usual way to obtain the application package (as a string) on Android is invoking getPackageName() on an Activity or Application instance: String Context.getPackageName(); This method is not static, i.e. you must first have a Context instance at hand in order to obtain the package name. But it feels like it should be possible to [...]

Fast clamp

Sometimes one needs to bound a value between two limits, min and max. This operation is called clamp. Let’s consider the clamp of an integer to the interval [0, 255]. int clamp(int x) { return x 255 ? 255 : x; } JPEG decoding requires three such clamp operations per decoded pixel, so we’d like [...]

The first Galaxy Nexus challenge too hard for anybody

Google posted the first Galaxy Nexus challenge, which proved too difficult for anybody to solve. After 3 hours of waiting for a solution, Google gave in and posted a spoiler hint Dots are like flag messages, which makes the challenge pretty much trivial. It looks like the initial task was too hard (nobody was solving [...]

Thanks to Eric Sink for his new book

I just received by international mail the printed edition of Version Control by Example by Eric Sink, offered as a gift. Thanks!

Fast RGB pixel average on ARM

Here I present a small trick, how to compute extremely fast the average of two RGBA_8888 values on an ARM processor, and how to implement it easily in C++/gcc (e.g. using the Android NDK). We have two 4-byte values representing two pixels, in format RGBA_8888. Let’s ignore the Alpha channel, assuming both have alpha=0xff (opaque). [...]

Android ARM: PLD preload magic

I just discovered the incredible performance boost that can be achieved by using the PLD (“Preload Data”) ARM assembler instruction. What I needed to do is convert image pixel data from RGB to RGBA format — from 3bytes/pixel to 4bytes/pixel; fullscreen in real time during animation. But the general situation is anytime you need to [...]