All Projects → lijiankun24 → Koala

lijiankun24 / Koala

从 Java 字节码到 ASM 实践

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Koala

Jaop
jaop is a gradle plugin base on javassist&asm for android aop
Stars: ✭ 115 (+11.65%)
Mutual labels:  gradle-plugin, asm, aop
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (+69.9%)
Mutual labels:  gradle-plugin, asm, aop
Laziertracker
本项目通过Android字节码插桩插件实现Android端无埋点(或自动埋点),并且支持根据配置文件实现业务数据的自动采集。
Stars: ✭ 485 (+370.87%)
Mutual labels:  gradle-plugin, asm, aop
Hunter
A fast, incremental, concurrent framework to develop compile plugin for android project to manipulate bytecode
Stars: ✭ 999 (+869.9%)
Mutual labels:  gradle-plugin, hugo, asm
Audiovideocodec
一款视频录像机,支持AudioRecord录音、MediaCodec输出AAC、MediaMuxer合成音频视频并输出mp4,支持自动对焦、屏幕亮度调节、录制视频时长监听、手势缩放调整焦距等
Stars: ✭ 113 (+9.71%)
Mutual labels:  gradle-plugin, aop
Codeguide
📚 本代码库是作者小傅哥多年从事一线互联网 Java 开发的学习历程技术汇总,旨在为大家提供一个清晰详细的学习教程,侧重点更倾向编写Java核心内容。如果本仓库能为您提供帮助,请给予支持(关注、点赞、分享)!
Stars: ✭ 6,750 (+6453.4%)
Mutual labels:  asm, aop
Androidanimationexercise
Android 动画各种实现,包括帧动画、补间动画和属性动画的总结分享
Stars: ✭ 1,254 (+1117.48%)
Mutual labels:  gradle-plugin, asm
Bytex
ByteX is a bytecode plugin platform based on Android Gradle Transform API and ASM. 字节码插件开发平台
Stars: ✭ 2,140 (+1977.67%)
Mutual labels:  gradle-plugin, asm
Androidautotrack
Android Asm 插桩 教学
Stars: ✭ 378 (+266.99%)
Mutual labels:  gradle-plugin, asm
Let
Annotation based simple API flavored with AOP to handle new Android runtime permission model
Stars: ✭ 532 (+416.5%)
Mutual labels:  gradle-plugin, aop
Module Service Manager
Android模块化/组件化通信框架
Stars: ✭ 58 (-43.69%)
Mutual labels:  gradle-plugin, asm
Methodtraceman
用于快速找到高耗时方法,定位解决Android App卡顿问题。通过gradle plugin+ASM实现可配置范围的方法插桩来统计所有方法的耗时,并提供友好的界面展示,支持耗时筛选、线程筛选、方法名筛选等。(A Tool for Discovering High Time-consuming Methods for Android App)
Stars: ✭ 1,258 (+1121.36%)
Mutual labels:  gradle-plugin, asm
Educenter Hugo
Educenter is an educational website template. It can be used as an online teaching platform, school and university websites
Stars: ✭ 96 (-6.8%)
Mutual labels:  hugo
Hugo Octopress
Port of the classic Octopress theme to Hugo
Stars: ✭ 99 (-3.88%)
Mutual labels:  hugo
Pulp
Pulp is a Hugo theme for getting a simple, easy-to-read blog site.
Stars: ✭ 95 (-7.77%)
Mutual labels:  hugo
Swifthook
A library to hook methods in Swift and Objective-C.
Stars: ✭ 93 (-9.71%)
Mutual labels:  aop
Hugo Theme Nix
Nix is a simple, minimal theme for Hugo
Stars: ✭ 101 (-1.94%)
Mutual labels:  hugo
Hugo Theme Even
🚀 A super concise theme for Hugo https://hugo-theme-even.netlify.app
Stars: ✭ 1,351 (+1211.65%)
Mutual labels:  hugo
Compose
A Hugo theme for documentation sites. It's inspired by https://forestry.io/docs/welcome/
Stars: ✭ 95 (-7.77%)
Mutual labels:  hugo
Blogdown
Create Blogs and Websites with R Markdown
Stars: ✭ 1,327 (+1188.35%)
Mutual labels:  hugo

Koala

Download

相关博文

在开发之前学习了一些 Java 字节码、Java 虚拟机、ASM 的相关知识,梳理成博文如下,请多多指教

简介

  • 在开发项目的时候,经常会想看一个方法的入参、返回结果和执行耗时,我们通常的做法是打日志、打断点调试去看,这样做确实可以达到我们的目的,但是效率是低下的。
  • JakeWharton 大神的 hugo 库便具有这样的功能,可以打印方法的入参、返回结果和执行耗时。
  • Koala 也具有和 hugo 同样的功能,可以打印方法的入参、返回结果和执行耗时。Koala 和 hugo 都是基于 AOP 思想,和 hugo 不同的是,hugo 使用 AspectJ 技术实现的,而 Koala 是使用 ASM 修改字节码实现的。

添加依赖

添加 Koala Gradle Plugin 依赖

在项目工程的 build.gradle 中添加如下代码:

    buildscript {
        repositories {
            maven {
                url "https://plugins.gradle.org/m2/"
            }
        }
        dependencies {
            classpath "gradle.plugin.com.lijiankun24:buildSrc:1.1.1"
        }
    }

在需要使用的 module 中的 build.gradle 中添加如下代码:

    apply plugin: "com.lijiankun24.koala-plugin"

添加 Koala 依赖

Gradle:

    compile 'com.lijiankun24🐨x.y.z'

Maven:

    <dependency>
        <groupId>com.lijiankun24</groupId>
        <artifactId>koala</artifactId>
        <version>x.y.z</version>
        <type>pom</type>
    </dependency>

替换上面的 xyz为最新的版本号: Download

使用

使用起来还是非常简单的,在 Java 的方法上添加 @KoalaLog 注解,如下所示:

    @KoalaLog
    public String getName(String first, String last) {
        SystemClock.sleep(15); // Don't ever really do this!
        return first + " " + last;
    }

当上述方法被调用的时候,Logcat 中的输出如下所示:

09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/0KoalaLog: ┌───────────────────────────────────------───────────────────────────────────------
09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/1KoalaLog: │ The class's name: com.lijiankun24.practicedemo.MainActivity
09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/2KoalaLog: │ The method's name: getName(java.lang.String, java.lang.String)
09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/3KoalaLog: │ The arguments: [li, jiankun]
09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/4KoalaLog: │ The result: li jiankun
09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/5KoalaLog: │ The cost time: 15ms
09-04 20:51:38.008 12076-12076/com.lijiankun24.practicedemo I/6KoalaLog: └───────────────────────────────────------───────────────────────────────────------

混淆规则

 -keep class com.lijiankun24.koala.** { *; }

About Me

鸣谢

感谢以下四个库和它的作者:

License

 Copyright 2018, lijiankun24

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].