안드로이드 오픈 소스를 import 하여 사용중 switch case 문에서 Non-Constant Expressions : Migration Necessary 라는 오류가 발생하였다.

 

상세 내용


 

Non-Constant Expressions : Migration Necessary



As of ADT 14, the resource fields (such as R.id.img_btn_submit_auth) are no longer

constants when defined in library projects This is necessary to make library projects

reusable without recompiling them.



One consequence of this that you can no longer use the fields directly in switch

statements. You must use an if-else chain instead.


Ecplipse can automatically convert from a switch statement to an if-else statement.

Just place the caret on the switch keyword and invoke Quick Fix Ctrl-1 on Windows and 

Linux, Cmd-1 on Mac) then select "Convert 'switch' to if-else".


for more information, see :http://tools.android.com/tips/non-constant-fields


 


isLibrary로 되어 있는 프로젝트의 경우 Res영역이 상수가 아니기 때문에 case expressions must be constant expressions 문제가 발생한다고 한다.

 

해결방법으로 swich case문 대신 if else 문을 사용하였다.



 

+ Recent posts