Android introduces hunter-debug to monitor code runtime function time consumption, parameters and return values, Java (1)
(1) Add cn.quinnchen.hunter:hunter-debug-plugin reference in the root build.gradle file of the project:
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) Add references and configuration plugins to the build.gradle of the current app module:
plugins {
id 'com.android.application'
id 'hunter-debug'
}
dependencies {
implementation 'cn.quinnchen.hunter:hunter-debug-library:1.2.3'
}
(3) Upper Java code:
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);
}
}
}
Run output:
https://github.com/Leaking/Hunterhttps://github.com/Leaking/Hunter