Android 引入hunter-debug监测代码运行时函数耗时和参数及返回值,Java(1)
(1)在工程的根build.gradle文件里面添加cn.quinnchen.hunter:hunter-debug-plugin引用:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'cn.quinnchen.hunter:hunter-debug-plugin:1.2.3'
classpath 'cn.quinnchen.hunter:hunter-transform:1.2.3'
}
}
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
}
(2)在当前app模块的build.gradle添加引用和配置插件:
plugins {
id 'com.android.application'
id 'hunter-debug'
}
dependencies {
implementation 'cn.quinnchen.hunter:hunter-debug-library:1.2.3'
}
(3)上层Java代码:
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.hunter.library.debug.HunterDebug;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
longTimeWork();
}
@HunterDebug
private void longTimeWork(){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
运行输出:
https://github.com/Leaking/Hunterhttps://github.com/Leaking/Hunter