react 前端框架如何驱动企业数字化转型与创新发展
696
2022-11-02
展示 Android 程序方法调用链的 gralde 插件,支持输出html文件和方法折叠
Method Tracking
A plugin to display how methods are called in application.
Live Demo
Usage
Stpe1
Add these to your root build.gradle.
buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "gradle.plugin.com.uniquestudio:method-tracking:1.0.6" }}
Don't forget :
apply plugin: "com.uniquestudio.method-tracking"
Step2
First find where you want to debug.In my demo I care about how to wear cloth,so I add two lines around wearCloth like this:
Debug.startMethodTracing(getPackageName());wearCloth();Debug.stopMethodTracing();public void wearCloth() { putOnCoat(); putOnPants(); putOnShoes(); putOnHat();}private void putOnPants() {}private void putOnCoat() {}private void putOnHat() { // Put on hat}public void putOnShoes() { putOnSocks(); // Put on shoes}public void putOnSocks() { // Put on socks}
Step3
Now let's start configure this plugin.In your app module, add method-tracking closure.
methodTracking{ traceName = 'com.hackerli.sample.trace' filterList = ['com.hackerli.sample']}
traceName is from the method Debug.startMethodTracing(traceName)filterList is used to filter some extra methods.We usually use package name.
Step4
./gradlew track
After above steps,traceName.html is created.
Its output like this:
The digit is useces.
In html,I add click event that means you can toggle these elements that have children.For example if I click com.hackerli.sample.MainActivity.putOnShoes above line,I will get:
THANKS
I am inspired by AppMethodOrder,espically how to compatible Windows os in groovy script or gradle script.
LICENSE
Copyright 2017 coxier.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 athttp://apache.org/licenses/LICENSE-2.0Unless 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.
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~