Android以aar包形式引入hunter-debug,Java(3)

Android以aar包形式引入hunter-debug,Java(3)

(1)首先把hunter的master分支代码拉下来,在本地编译,

https://github.com/Leaking/Hunterhttps://github.com/Leaking/Hunter此过程主要目的是获得各个模块的aar文件,因为Android Studio在编译apk时候,顺带也生成了对外可调用的aar包文件。如果这一阶段编译有问题,可以切换低版本的gradle试试。

(2)把第(1)阶段生成的hunter-debug-library-debug.aar放入到当前项目的libs目录下。

(3)在工程根目录的build.gradle配置:

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
}

(4)在app的build.gradle配置:

plugins {
    id 'com.android.application'
    id 'hunter-debug'
}

android {
    
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar","*.aar"])
}

(5)上层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);
        fun1();
    }

    @HunterDebug
    private boolean fun1(){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        return false;
    }
}

输出:

6f12bd4bd1984f0087dfb4622e168758.png

Android 引入hunter-timing监测UI主线程函数运行时耗时,Java(2)_zhangphil的博客-CSDN博客Android 引入hunter-debug监测代码运行时函数耗时和参数及返回值,Java(1)_zhangphil的博客-CSDN博客。Android 引入hunter-debug监测代码运行时函数耗时和参数及返回值,Java(1)Android 引入hunter-timing监测UI主线程函数运行时耗时,Java(2)同时重载Application,https://blog.csdn.net/zhangphil/article/details/130590914

Android 引入hunter-debug监测代码运行时函数耗时和参数及返回值,Java(1)_zhangphil的博客-CSDN博客Android 引入hunter-debug监测代码运行时函数耗时和参数及返回值,Java(1)https://blog.csdn.net/zhangphil/article/details/130590724

猜你喜欢

转载自blog.csdn.net/zhangphil/article/details/130603231