开发者

How to retrieve view id from application compiled and obfuscated by proguard?

开发者 https://www.devze.com 2023-04-05 06:46 出处:网络
I\'m writing tests for application that is compiled and obfuscated. Currently to access View I use Id form /res/values/public.xml

I'm writing tests for application that is compiled and obfuscated. Currently to access View I use Id form /res/values/public.xml

View myView = solo.getView(0x7f0b0030);
solo.clickOnView(((LinearLayout) (myView)).getChildAt(3));

This approach is valid开发者_开发问答 only util application is not recompiled.

Is there any way to acces view by Id without having R file?


You can access ID of a resource by name using Resources class.

For example:

getResources().getIdentifier("my_image", "drawable", "com.my_package");

The same trick should work for layout as well.


AFAIK there is no method to access Id without R file.

If you came to know about solution please share your finding so that other can also benefitted.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号