Android Resource and the Eclipse switch Quick Fix

In the process of updating and refactoring an old Android project I unwittingly changed a Project configuration option (the “Is Library” option) that lead to my resource file being generated differently. E.g


public final class R {
public static final class id {
public static final int button1=0x7f090001;
public static final int button2=0x7f090002;
public static final int button3=0x7f090003;


public final class R {
public static final class id {
public static int button1=0x7f090001;
public static int button2=0x7f090002;
public static int button3=0x7f090003;

A subtle change indeed but one that caused the following compiler error for each line

case expressions must be constant expressions

Some googling lead me to a Stack Overflow page wherein I found the root cause.

Most interestingly though, I came across the Quick Fix that would convert a switch statement into an if-else statement.

You can quickly convert a switch statement to an if-else statement using Eclipse’s quick fix.

Click on the switch keyword and press Ctrl + 1 then select

Convert ‘switch’ to ‘if-else’.

What I would have given to have capability in some previous projects!

Published by LucasPardue

Working on technology and Internet standards such as HTTP/2, HTTP/3 and QUIC.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.