MCPcopy Index your code
hub / github.com/Leaking/Hunter

github.com/Leaking/Hunter @v1.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.3.1 ↗ · + Follow
304 symbols 636 edges 73 files 46 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Hunter

Maven Central Build License

中文

Hunter is a framework to develop android gradle plugins based on ASM and the modern AGP Instrumentation API. It provides a set of useful, scalable plugins for android developers. You can use Hunter to develop more plugins to monitor your app, enhance 3rd-party deps, or enhance the android framework. Hunter-based plugins inherit AGP's incremental, parallel instrumentation pipeline, so you don't pay for extra build time.

Latest Version

Hunter is published to Maven Central.

All libraries and plugins share the same version number. Replace LATEST_VERSION_IN_README in the per-plugin READMEs with the latest version shown in the badge above.

def hunterVersion = '1.3.1'

Compatibility

Hunter Android Gradle Plugin Gradle ASM Java
1.3.x 7.4 – 8.7+ 8.0+ 9.7 17
1.2.x 4.x (legacy Transform API, removed in AGP 8) 7.x 7.1 8

1.3.0 is a breaking release: the legacy Transform API is gone (it was removed by AGP 8.0 — see issues #67, #63, #34) and Hunter now wires itself in via AndroidComponentsExtension.onVariants + AsmClassVisitorFactory. ASM was bumped to 9.x to support Java 17 records and sealed classes (#60, #66). The constructor instrumentation bug from #48 is also fixed: the timing probe is now injected after the mandatory super(...) / this(...) call.

Some useful plugins based on Hunter

  • OkHttp-Plugin: Hack Okhttp to set a global Interceptor/Eventlistener/Dns for all your OkhttpClients, even clients in 3rd-party library.
  • Timing-Plugin: you can time all your ui-thread methods, and dump the block traces with costed-time of every step, you also can consume the block detail in your way.
  • Debug-Plugin: you can simply add a annotation to a certain method, and the method will print all parameters and costed time, return value. It has many advantages over JakeWharton's hugo
  • LogLine-Plugin: you can add a line number into every lines of your logcat

TODO

More developing plugins can be found in TODO, MeanWhile, your idea is welcome

Developer API

If you want to use hunter to develop a gradle plugin to modify bytecode, please read Wiki

Social network

Welcome to join:

Telegram group: https://t.me/joinchat/BalX-RxnM9ETca1iwgDaFQ

WeChat group:

如果二维码过期了,加微信拉群 742223410

License

Copyright 2018 Quinn Chen

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.

Extension points exported contracts — how you extend this code

IWeaver (Interface)
(no doc) [6 implementers]
hunter-transform/src/main/java/com/quinn/hunter/transform/asm/IWeaver.java
IBlockHandler (Interface)
Created by quinn on 11/09/2018 [4 implementers]
hunter-timing-library/src/main/java/com/hunter/library/timing/IBlockHandler.java
Constants (Interface)
(no doc)
hunter-debug-library/src/main/java/com/hunter/library/debug/Constants.java
TimingHunterParameters (Interface)
(no doc)
hunter-timing-plugin/src/main/groovy/com/quinn/hunter/plugin/timing/TimingHunterParameters.java
OkHttpHunterParameters (Interface)
(no doc)
hunter-okhttp-plugin/src/main/groovy/com/quinn/hunter/plugin/okhttp/OkHttpHunterParameters.java
HunterParameters (Interface)
Common Gradle task parameters shared by every Hunter ASM visitor factory. Subclass this for plugin-specific parameters;
hunter-transform/src/main/java/com/quinn/hunter/transform/HunterParameters.java

Core symbols most depended-on inside this repo

append
called by 41
hunter-debug-library/src/main/java/com/hunter/library/debug/ParameterPrinter.java
i
called by 34
hunter-linelog-library/src/main/java/com/hunter/library/linelog/LineNumberLog.java
formatReturn
called by 20
hunter-debug-library/src/main/java/com/hunter/library/debug/ResultPrinter.java
visitVarInsn
called by 19
hunter-timing-plugin/src/main/groovy/com/quinn/hunter/plugin/timing/bytecode/TimingMethodAdapter.java
visitLdcInsn
called by 19
hunter-timing-plugin/src/main/groovy/com/quinn/hunter/plugin/timing/bytecode/TimingMethodAdapter.java
toString
called by 18
hunter-debug-plugin/src/main/groovy/com/quinn/hunter/plugin/debug/DebugHunterExtension.java
visitMethodInsn
called by 15
hunter-timing-plugin/src/main/groovy/com/quinn/hunter/plugin/timing/bytecode/TimingMethodAdapter.java
emitDeferredStartProbe
called by 13
hunter-timing-plugin/src/main/groovy/com/quinn/hunter/plugin/timing/bytecode/TimingMethodAdapter.java

Shape

Method 229
Class 67
Interface 7
Enum 1

Languages

Java98%
Kotlin2%

Modules by API surface

hunter-debug-example/src/main/java/com/quinn/hunter/debug/MainActivity.java20 symbols
hunter-timing-plugin/src/main/groovy/com/quinn/hunter/plugin/timing/bytecode/TimingMethodAdapter.java18 symbols
hunter-timing-library/src/main/java/com/hunter/library/timing/impl/StacktraceBlockHandler.java14 symbols
hunter-timing-library/src/main/java/com/hunter/library/timing/impl/RankingBlockHandler.java12 symbols
hunter-debug-plugin/src/main/groovy/com/quinn/hunter/plugin/debug/bytecode/prego/DebugPreGoClassAdapter.java11 symbols
hunter-transform/src/main/java/com/quinn/hunter/transform/HunterPlugin.java8 symbols
hunter-okhttp-example/src/main/java/com/quinn/hunter/okhttp/CustomGlobalEventListener.java8 symbols
hunter-timing-example/src/main/java/com/quinn/hunter/timing/DataSource.java7 symbols
hunter-linelog-library/src/main/java/com/hunter/library/linelog/LineNumberLog.java7 symbols
buildSrc/src/main/java/Dependencies.kt7 symbols
hunter-okhttp-library/src/main/java/com/hunter/library/okhttp/OkHttpHooker.java6 symbols
hunter-debug-plugin/src/main/groovy/com/quinn/hunter/plugin/debug/bytecode/prego/DebugPreGoMethodAdapter.java6 symbols

For agents

$ claude mcp add Hunter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact