Status Update
Comments
xa...@google.com <xa...@google.com> #2
Iza, can you check if this is a model builder problem or strictly in Studio?
cm...@google.com <cm...@google.com> #3
This lint check is intentional - we wanted to give warning about the transition
Currently the warning is
Warning: Non-constant resource ID should not be used as switch case
with description
Avoid the usage of resource IDs where constant expressions are required.
A future version of the Android Gradle Plugin will generate R classes with
non-constant IDs in order to improve the performance of incremental compilation.
We need to tweak the summary wording to make it clearer that this relates to a future compatibility issue with AGP.
im...@google.com <im...@google.com>
im...@google.com <im...@google.com> #4
Perhaps we could work on the wording of the main warning to make it a little more user-friendly.
[Deleted User] <[Deleted User]> #5
Please explain how I'm supposed to use something like Butterknife, that has annotations that take R references?
xa...@google.com <xa...@google.com> #6
Butterknife should mostly be replaced with viewbinding.
[Deleted User] <[Deleted User]> #7
Ok. I guess I'll throw that task onto the backlog.
xa...@google.com <xa...@google.com> #8
Sorry my previous message was too terse.
We'll have a period when you can disable the new mode when we do introduce it. Feedback about whether there is something that prevents you from using it very useful to us. If something else is blocking you, please do let us know.
At this point, my understanding is that ButterKnife is not maintained anymore in favor of viewbinding, so you should think about moving to it at some point (when it's convenient for you).
[Deleted User] <[Deleted User]> #9
That's a fair recommendation, and ultimately why I just agreed with you, despite your terseness :) I avoid butterknife in all new code, but the project I'm on uses it extensively, so it's just a matter of prioritization, which I know you understand.
(maybe I should revive an old semi-joke plugin I was working on called NoButterknife, which failed a build if it found butterknife in it... hmmm)
cm...@google.com <cm...@google.com> #10
For butterknife you can also use the same plugin you use for libraries to generate the R2 class and use that even after AGP removes this flag.
[Deleted User] <[Deleted User]> #11
Honestly I'm sort of happy to have more force behind my recent "remove butterknife" ticket.
cm...@google.com <cm...@google.com> #12
It it helps, using the butterknife plugin isn't free - it essentially undoes the performance optimizations we have done to the r-class processing
[Deleted User] <[Deleted User]> #13
I just noticed that this lint check also fires when using a resource ID in a switch statement. What's the new hotness for doing the following?
public void onItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.hello_world:
cm...@google.com <cm...@google.com> #14
In java, you need to use a chained if
, the same as you would have had to do if you were writing that code in a library today.
Kotlin's when
allows non constant case expressions.
zh...@gmail.com <zh...@gmail.com> #16
I saw this issue in AGP 4.1.0-beta05 release notes, but would like to consult whether raising lint warning check on android.R is a false positive.
Description
Build: AI-201.7223.91.41.6565218, 202006060743,
AI-201.7223.91.41.6565218, JRE 1.8.0_242-release-1644-b3-6222593x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.15.4, screens 1920x1080, 1920x1080
AS: 4.1 Beta 1; Kotlin plugin: 1.3.72-release-Studio4.1-5; Android Gradle Plugin: 4.0.0; Gradle: 6.3; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: (not found)
IMPORTANT: Please readhttps://developer.android.com/studio/report-bugs.html carefully and supply all required information.
This is a very simple project, just a single app module. I have not enabled the option to turn app IDs non-final to improve build performance.