Fixed
Status Update
Comments
ai...@gmail.com <ai...@gmail.com> #3
This is still an issue for our project.
Reproduced on Command Line Lint with Gradle with DataBinding compiler v2
Reproduced on Command Line Lint with Gradle with DataBinding compiler v2
uc...@google.com <uc...@google.com> #4
Can you share a sample project to reproduce this issue.
ai...@gmail.com <ai...@gmail.com> #5
I just reproduced this issue. You can reproduce it if use resource as R class field (like R.string.hello) instead of standard Android @ resouce notation (@string/hello)
You can check it here, just run lint on this project:
https://github.com/gildor/kotlin-android-sample
Lint will complain about "toolbar_title" resource
You can see that resource is actually used by bindings like R.string.toolbar_title:https://github.com/gildor/kotlin-android-sample/blob/8fb6c9843886afe197a431f68e9b6e26ee13f0f9/app/src/main/res/layout/activity_main.xml#L22
In this particular case, you can use @resource notation, but it's not always possible in some other cases (for example when you pass drawable id to some function, and bindings will convert it to Drawable class instead if you use @ notation), so this cause this issue with false-positive lint warning
You can check it here, just run lint on this project:
Lint will complain about "toolbar_title" resource
You can see that resource is actually used by bindings like R.string.toolbar_title:
In this particular case, you can use @resource notation, but it's not always possible in some other cases (for example when you pass drawable id to some function, and bindings will convert it to Drawable class instead if you use @ notation), so this cause this issue with false-positive lint warning
ai...@gmail.com <ai...@gmail.com> #6
Also one case: you cannot specify menu resource with @ notation and you must use R class import, so this also cause lint warning
uc...@google.com <uc...@google.com> #7
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
[Deleted User] <[Deleted User]> #8
An issue for us too with string and layout resources. any updates
[Deleted User] <[Deleted User]> #9
An issue for us too with string that only used in kotlin code. any updates
[Deleted User] <[Deleted User]> #10
Still same issue with Studio 3.2-rc1
vs...@google.com <vs...@google.com> #11
David - would you be able to triage this? (And work with Matthew if you need lint side help).
da...@google.com <da...@google.com> #12
(I realize I should reply publicly instead of just triaging in the background - I don't think external users can see the hotlist annotations I'm making.)
Our team will look into this, and we'll reach to Matthew if we have any questions. Thanks Siva!
Our team will look into this, and we'll reach to Matthew if we have any questions. Thanks Siva!
ai...@gmail.com <ai...@gmail.com> #13
Are there any updates on this issue?
It prevents us from the usage of UnusedResources lint check, which is one of the most useful, we can use it manually, but it requires a lot of time to check each reported resource
It prevents us from the usage of UnusedResources lint check, which is one of the most useful, we can use it manually, but it requires a lot of time to check each reported resource
da...@google.com <da...@google.com> #14
Sorry for lack of updates. We're working on similar areas right now. Referencing String resources has a complex set of challenges, so it's been hard to effectively estimate when we can fix this.
ai...@gmail.com <ai...@gmail.com> #15
What about other resources? Because I see that it's an issue for any kind of resources that referenced from binding using R class
da...@google.com <da...@google.com> #16
Sorry for writing a comment that just emphasized String resources. If we fix it for Strings, that should fix it for all resource types as well. Kainan, who is working on this, may know more than me, so if he follows up with a comment that contradicts me, listen to him instead :)
ai...@gmail.com <ai...@gmail.com> #18
Wow, great news! Will try with our project when Canary 4 will be released
Is there any chance that it would eventually be backported on AGP 3.6?
Is there any chance that it would eventually be backported on AGP 3.6?
da...@google.com <da...@google.com> #19
I'm guessing we won't be able to backport, because we're already a few releases into our beta, so we'd have to present a very clear risk / reward justification. But I'll try to chase it down today to confirm..
Description
all required information.
Studio Build: 3.0.1 Nov 9, 2017
Version of Gradle Plugin: 3.0.1
Version of Gradle: 4.1
Version of Java: 1.8.0_60
OS: Windows 7
Steps to Reproduce:
1. Start with a project that uses Android Databinding and has layout XML files that use code that references android string resources
2. Run Analyze / Run Inspection By Name / Unused Resources
3. Delete reported unused references
4. Try and build. You will find that you just deleted references from generated databinding classes
Android studio knows if a string resource has references because Find Usages in strings.xml file find references in generated binding classes. Unfortunately this is not used by Android Lint which is apparently behind the Analyze / Run Inspection By Name / Unused Resources feature