在组件化开发中,当我们使用switch来进行判断操作时,会报这个错误,原因是R.id.XXX这类资源id在主application中是final,是常量,而在library中,是没有final的。这里盗个图:

Resource IDs cannot be used in a switch statement in Android library modules.

所以我们需要将switch转变为if else,直接选中switch,alt+enter,选择replace switch with if .

相关文章:

  • 2022-12-23
  • 2021-06-21
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2021-04-21
猜你喜欢
  • 2021-12-12
  • 2021-12-05
  • 2021-07-24
  • 2021-11-25
  • 2022-12-23
  • 2021-05-20
相关资源
相似解决方案