Android Lib Project中生产的R文件内,都不是常量。
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
public final class R {
public static final class string {
public static int action_settings=0x7f050001;
public static int app_name=0x7f050000;
public static int hello_world=0x7f050002;
}
}
Android Project中生产的R文件内,都是常量。
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
public final class R {
public static final class string {
public static final int action_settings=0x7f050001;
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050002;
}
}
所以当你的项目中有用到switch的地方,同时条件又用到了 R 中的常量时,将此project转成lib project的话就会报错。要求你将 switch-case 换成 if-else。
As of ADT 14, resource fields cannot be used as switch cases. Invoke this fix to get more information.
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsISMzMzMwkDNzETMxMDM1EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)