
Template details
Koala
A Java/Android AOP library that logs method arguments, return values, and execution time using ASM bytecode manipulation.
About this template
Koala is a Java/Android AOP library that logs method arguments, return values, and execution time by modifying bytecode with ASM at compile time.
What is Koala?
Koala is an open-source Java/Android library created by lijiankun24 that prints a method's class name, method signature, arguments, return result, and execution time to Logcat when that method is annotated with @KoalaLog. It operates as a Gradle plugin plus runtime library, and implements AOP through ASM bytecode rewriting rather than AspectJ. The project is released under the Apache License 2.0 and had 145 stars at the time of this description.
What makes Koala stand out?
- ASM-based bytecode modification — Koala rewrites compiled class files directly using the ASM library, in contrast to Hugo which uses AspectJ, making it lighter for Android builds.
- Single-annotation API — Add
@KoalaLogto any Java method to get structured Logcat output; no manual logging code required. - Structured log output — Each invocation prints a bordered block containing the class name, full method signature with parameter types, argument values, the returned value, and execution time in milliseconds.
- Gradle plugin integration — The build is configured by applying the plugin
com.lijiankun24.koala-pluginin the module's build.gradle and adding thecom.lijiankun24:koaladependency. - ProGuard support — The documentation ships a keep rule (
-keep class com.lijiankun24.koala.**) so the library survives release builds with minification enabled. - Compatible with Java methods — The annotation works on Java methods, demonstrated with a
getNameexample that prints arguments and result.
Who is Koala for?
- Android developers — who want to quickly inspect method inputs and outputs during debugging without writing log statements.
- Developers working on API integration — who need to trace the arguments and return values of library or network calls.
- Performance-conscious developers — who want to measure execution time of specific methods in milliseconds during development.
What can you do with Koala?
- Debug method calls: Annotate any Java method with
@KoalaLogand the next invocation will print the class name, method signature, arguments, return value, and elapsed time in Logcat. - Track costly operations: Wrap methods that perform I/O or complex calculations to see their exact runtime in milliseconds.
- Verify API arguments and responses: For methods that wrap web service calls, Koala shows both the request arguments and the returned result in one log block.
How does Koala work?
Koala is installed in three steps. First, add the Gradle plugin to the project's build classpath using gradle.plugin.com.lijiankun24:buildSrc:1.1.1. Second, apply the plugin with apply plugin: "com.lijiankun24.koala-plugin" in the module and add the runtime dependency com.lijiankun24:koala. Finally, annotate any Java method with @KoalaLog; at build time ASM rewrites the method's bytecode to insert logging around the original implementation.
Alternatives
- Hugo — Jake Wharton's library with the same logging goal, but it uses AspectJ instead of ASM and may require more build configuration on Android.
- CostTime — a similar method timing library that Koala's author explicitly thanks in the README.
- AppMethodTime — another Android method-time tracing library listed in the acknowledgments.
FAQ
Is Koala free?
Yes, Koala is open source and released under the Apache License 2.0, so it is free to use, modify, and redistribute.
What is the difference between Koala and Hugo?
Both log method arguments, results, and execution time, but Koala implements AOP via ASM bytecode modification while Hugo uses AspectJ. Koala is distributed as a Gradle plugin plus runtime dependency, which may be simpler to integrate in Android projects.
Does Koala work with Kotlin?
The README only shows Java usage with the @KoalaLog annotation on Java methods. There is no explicit statement about Kotlin support.
How do I add Koala to my project?
Add the plugin to the buildscript dependencies, apply the plugin, add the com.lijiankun24:koala dependency, and then annotate methods with @KoalaLog. ProGuard configuration is also provided.
















