I would like to integrate zxing into my app. I'm importing project, set it as library, change target to API 7, download zxing-core-2.2.jar, copy it to /libs and add this jar in Java Building Path as library.
But there are still some errors:
All of them are in switch statements and depend on R.id. for example:
switch (item.getItemId()) {
case R.id.menu_share:
Eclipse error description:
case expressions must be constant expressions
there is a info dialog:
Any idea what I'm doing wrong or how to fix it?
As explained in the dialog you have shown, R.id.menu_settings is now "no longer constant", which means it cannot be used in a switch. the dialog also provides the solution, instead of
switch (item.getItemId()) {
case R.id.menu_share:
//do something
break;
case xxx:
...
}
You should do this:
if(item.getItemId()==R.id.menu_share) {
//do something
} else if (item.getItemId()==xxx) {
//do something
}
Just follow the instruction and you should be fine.
The problem is the source of zxing is not intended to be used as a Library.. Please see the answer by Sean in the below thread.
Zxing project as library in a project won't build
I tried bridling my app within this CaptureActivity project adding my activity and resources and modifying its manifest File accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With