How to resolve "Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements" warning? [duplicate] How to resolve "Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements" warning? [duplicate] android android

How to resolve "Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements" warning? [duplicate]


The issue happens because since ADT 14 resource identifiers are no longer final.

See the next link, where Google states to use instead "if/else" conditions as alternative:

http://tools.android.com/tips/non-constant-fields

That being said. when it comes to performance, "switch" statements may perform better than "if/else" conditions.

However, in your case, you do not gain or lose performance or efficiency.

The type of performance that a "switch" statement may give, has to be taken into consideration for more specific edge cases which may require high efficiency, such as render loops, or algorithms with efficiency in focus.

For your use-case, using an "if/else" condition is a good solution without efficiency issues.