leakcanary
leakcanary copied to clipboard
leak_canary_watcher_watch_dismissed_dialogs configuration incompatible with nonTransitiveRClass resources
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.
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?
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.
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.
Thank you for the investigation, that is workable for me until something better comes around.
Goal is to fix this by removing all XML configuration booleans.