Android R.java resource's Ids Non-constant Fields in Case Labels
来源:互联网 发布:手机淘宝店如何装修 编辑:程序博客网 时间:2024/05/16 10:03
Non-constant Fields in Case Labels
In a regular Android project, constants in the resource R class are declared like this:
public static final int main=0x7f030004;
However, as of ADT 14, in a library project, they will be declared like this:
public static int main=0x7f030004;
In other words, the constants are not final in a library project. The reason for this is simple: When multiple library projects are combined, the actual values of the fields (which must be unique) could collide. Before ADT 14, all fields were final, so as a result, all libraries had to have all their resources and associated Java code recompiled along with the main project whenever they were used. This was bad for performance, since it made builds very slow. It also prevented distributing library projects that didn't include the source code, limiting the usage scope of library projects.
The reason the fields are no longer final is that it means that the library jars can be compiled once and reused directly in other projects. As well as allowing distributing binary version of library projects (coming in r15), this makes for much faster builds.
the switch statement requires all the case labels, such as R.id.button1, to be constant at compile time(such that the values can be directly copied into the .class files).
In a regular Android project, constants in the resource R class are declared like this:
public static final int main=0x7f030004;
However, as of ADT 14, in a library project, they will be declared like this:
public static int main=0x7f030004;
In other words, the constants are not final in a library project. The reason for this is simple: When multiple library projects are combined, the actual values of the fields (which must be unique) could collide. Before ADT 14, all fields were final, so as a result, all libraries had to have all their resources and associated Java code recompiled along with the main project whenever they were used. This was bad for performance, since it made builds very slow. It also prevented distributing library projects that didn't include the source code, limiting the usage scope of library projects.
The reason the fields are no longer final is that it means that the library jars can be compiled once and reused directly in other projects. As well as allowing distributing binary version of library projects (coming in r15), this makes for much faster builds.
the switch statement requires all the case labels, such as R.id.button1, to be constant at compile time(such that the values can be directly copied into the .class files).
ref:
http://tools.android.com/tips/non-constant-fields
0 0
- Android R.java resource's Ids Non-constant Fields in Case Labels
- Non-constant Fields in Case Labels
- R.java case expressions must be constant expressions
- Validates using resource IDs in a switch statement in Android library module
- Resource IDs cannot be used in a switch statement in Android library modules
- android中 swich语句中的R文件出现case expressions must be constant expressions问题
- Keil提示错误error c221: non-constant case/dim expression
- ABAP--Printing barcode labels in SAP R/3
- ABAP--Printing barcode labels in SAP R/3
- android case expressions must be constant expressions
- Tips on non-standard evaluation in R
- Tips on non-standard evaluation in R
- 040902 R Internet 's resource (Page Link)
- Labels aligning in UITableViewCell
- Organize resource in Android
- android switch语句case expressions must be constant expressions
- android switch语句case expressions must be constant expressions
- android switch语句case expressions must be constant expressions
- 详解java定时任务(转载)
- Solr6.3.0部署tomcat
- request:fail 小程序要求的 TLS 版本必须大于等于 1.2
- 安卓源生实现计时器效果
- 移植QT4.8.7
- Android R.java resource's Ids Non-constant Fields in Case Labels
- sublime text 3 添加头文件代码段
- bean发布的报表添加随机名称
- ”_SecCertificateCopyData", referenced from:
- Java语言核心-使用try-catch捕获单个异常
- Python 日期和时间
- java基础学习
- 利用scikit-learn进行人脸表面关键点的定位
- 图片鉴黄的原理和应用