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

不支持setOnclickListener(new OnClick(){xxxxx})这种方式 #16

Open
qtfreet00 opened this issue Jan 16, 2020 · 6 comments
Open

不支持setOnclickListener(new OnClick(){xxxxx})这种方式 #16

qtfreet00 opened this issue Jan 16, 2020 · 6 comments

Comments

@qtfreet00
Copy link

button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                xxxxxxxxxxxxxxx
            }
        });

将如上代码如果写在方法里,如onCreate,转换后其实未实现onClick

@amimo
Copy link
Owner

amimo commented Jan 16, 2020

你的意思是这段代码被转换成native之后,功能就失效了?

@qtfreet00
Copy link
Author

应该是参数不支持interface类型的,OnClickListener是个interface

@qtfreet00
Copy link
Author

这部分没有转换,运行后将会直接crash

@amimo
Copy link
Owner

amimo commented Jan 16, 2020

我在测试用例里面测试了map的interface,没没有问题的.方便的话把测试代码发我,我研究下.

@amimo
Copy link
Owner

amimo commented Jan 16, 2020

@xmhwws
Copy link

xmhwws commented Jan 16, 2020

嘛,前来凑个热闹。

button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                xxxxxxxxxxxxxxx
            }
        });

将如上代码如果写在方法里,如onCreate,转换后其实未实现onClick

DCC支持的,没有问题。我的apk也有类似代码,可以正常运行。

未实现onClick

对于你这种情况(log提示该方法是java方法而不是native方法),如果你开启了混肴,我猜是混肴的锅。

我遇到过类似情况,排查了几个小时,才发现是混肴的原因。
在DCC之前,反编译你的apk,检查要DCC的类的smali文件名是否类似下面格式(句尾的.1.smali、.2.smali)(没错,混淆可以生成这种格式):
MainActivity$test.1.smali
MainActivity$test.2.smali
这种格式,DCC反编译apk,修改smali方法为native方法,无法处理这种文件名(这算是DCC的一个小bug?)。
如果有这种格式,换个混淆字典就行。

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