Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何weave onCreate一类无返回值的方法 #39

Open
xiachengcheng opened this issue Apr 14, 2020 · 2 comments
Open

如何weave onCreate一类无返回值的方法 #39

xiachengcheng opened this issue Apr 14, 2020 · 2 comments

Comments

@xiachengcheng
Copy link

@Proxy("onCreate")
@TargetClass("androidx.appcompat.app.AppCompatActivity")
public static void onCreate(@nullable Bundle savedInstanceState) {
Log.e(tag, "AppCompatActivity.onCreate");
Origin.callVoid();
}
没有Log出对应的信息
应该是没有weave成功

@ydslib
Copy link

ydslib commented Jun 26, 2020

我也是无法织入,感觉我的调用方法没啥问题

@penneryu
Copy link
Collaborator

虽然在 Proxy , Insert 中我们指定了方法名, 但识别方法必须要更细致的信息. 我们会直接使用 Hook 方法的修饰符,参数类型来匹配方法.
所以一定要保持 Hook 方法的 public/protected/private static 信息与目标方法一致,参数类型,返回类型与目标方法一致.

试试

@Proxy("onCreate")
@TargetClass("androidx.appcompat.app.AppCompatActivity")
protected void onCreate(Bundle savedInstanceState) {
    Log.e("aaa", "AppCompatActivity.onCreate");
    Origin.callVoid();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants