JavaStub is a simple utility for turning Android Dalvik Smali files into Java "stub" files.

Sometimes you need to interact with Android frameworks or applications that are closed source and undocumented. One part of this is discovering what methods and fields are available. Another part is generating what in other languages would be a "header file". You can generate Smali files from an .apk file using ApkTool. But the javac compiler can not work with Dex or Smali, it needs Java or JVM .jar files.


The new .jar file has no actual implementation. It is only there to compile against. If it were included in your own application it would not do anything. We want your application to use the code already on your device.


C:\>javastub PluginData.smali package android.webkit; public final class PluginData { public PluginData(InputStream stream, long length, Map headers, int code) {} public long getContentLength() { return(0); } public Map getHeaders() { return(null); } public InputStream getInputStream() { return(null); } public int getStatusCode() { return(0); } }

Parameter names are included when available. When not, they appear as the "p" register numbers. The numbers may not be contiguous as long and double use two registers.

C:\>javastub WebSettings$TextSize.smali package android.webkit; public enum TextSize { SMALLEST (0x32), SMALLER (0x4b), NORMAL (0x64), LARGER (0x96), LARGEST (0xc8); int value; private TextSize(int size) {} }

Note that enums are handled specially. Enums with values are extracted as documentation, though as the code is never executed it affects nothing. The /s flag may be used to generate simplified code without the values.

Other Uses

When browsing through decompiled code JavaStub can be helpful for seeing an overview of a class without wallowing through pages of smali.

Download javastub.exe for Win32