HujiangTechnology / gradle_plugin_android_aspectjx

A Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
Apache License 2.0
3.94k stars 568 forks source link

可以对三方库的一些方法hook吗? #36

Closed q960757274 closed 6 years ago

q960757274 commented 7 years ago

比如我想在vollry request类的add方法前做一些事情 代码如下: @Before("call(* com.android.volley.RequestQueue.add(..))") public void onGetVolleyHttpBefore(JoinPoint joinPoint) throws Throwable{ Log.v(TAG,"volley lib send request"); Object[] objects=joinPoint.getArgs(); Request request=(Request)objects[0]; Log.v(TAG,"volley lib request method="+request.getMethod()); String url=request.getUrl(); Log.v(TAG,"volley lib request url="+url); } 不生效,为什么?求大神

firefly1126 commented 7 years ago

可以hook任何第三方库里的方法,不生效的原因很可能是aspectjx 配置过滤的问题导致,你可以参数把过滤条件删除看看,aspectjx的过滤配置是这样的:

aspectjx {
    includeJarFilter ''
    excludeJarFilter ''
}

把它删掉看看。

q960757274 commented 7 years ago

Android 多 modual开发,不同modual之间可以hook吗

q960757274 commented 7 years ago

@firefly1126