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

leak_canary_watcher_watch_dismissed_dialogs configuration incompatible with nonTransitiveRClass resources #2466

Open
bubenheimer opened this issue Jan 19, 2023 · 5 comments
Milestone

Comments

@bubenheimer
Copy link

leakcanary 2.10

I don't believe the unusual configuration approach overriding the leak_canary_watcher_watch_dismissed_dialogs resource is compatible with non-transitive R classes (android.nonTransitiveRClass=true). Setting that resource in app code would simply create a new resource that is private to the app.

Non-transitive R classes are the default in Android now.

@pyricau
Copy link
Member

pyricau commented Jan 24, 2023

Interesting. Do you have documentation pointers on this?

Can you repro in a sample project and share it here? or e.g. by making changes to this repo in the sample app?

@bubenheimer
Copy link
Author

bubenheimer commented Jan 31, 2023

The main document link I see is this, but it does not say much about how it works:

https://developer.android.com/studio/build/optimize-your-build#use-non-transitive-r-classes

In essence, it creates a per-module namespace for the resources defined in the module. Before, in the source, all your resources would look like org.example.myapp.R.someresource, now they look like org.example.myapp.mymodule.R.someresource and org.example.myapp.myothermodule.R.someresource.

A module with non-transitive R classes turned on (the default now) cannot override another module's/library's resource anymore, because for compilation purposes the module's resource effectively ends up in the module's own resource namespace as a brand new resource. It gets its own numeric resource ID assigned at the end of the build.

Easiest way to verify this for yourself would be to override one of those UI-related leakcanary resources from a module with the android.nonTransitiveRClass flag true & false. Then you'd see changes in the UI.

@pyricau
Copy link
Member

pyricau commented Feb 7, 2023

I asked the god of Gradle and he said that once you set android.nonTransitiveRClass=true then you indeed cannot override resources from dependencies in any com.android.library modules, however you can still do that in your com.android.application module. Not ideal but at least that's a workaround.

@bubenheimer
Copy link
Author

Thank you for the investigation, that is workable for me until something better comes around.

@pyricau pyricau added this to the 3.0 milestone May 18, 2023
@pyricau
Copy link
Member

pyricau commented May 18, 2023

Goal is to fix this by removing all XML configuration booleans.

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

No branches or pull requests

2 participants