Saturday, September 26, 2020

Barcode scan and generate on Android

Bar code and QR code are widely used now. There is a lot of App can do the scan. I'm planing to make an app to scan Bar code and render it on cell phone display, so I can store bar code of my card and no longer need to carry the cards.

ZXing on github is a great choice as an open source solution. As the project home page mentioned: ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.

To get started, please visit: https://github.com/zxing/zxing/wiki/Getting-Started-Developing

Refer to this StackOverflow page for some example code. Get ZXing-2.1.zip from google code.

To use the lib with Android Studio, add this to app/build.gradle dependencies:

 implementation 'com.google.zxing:core:3.3.3'.

Sunday, September 20, 2020

Weird 'sdk version' problem with Android Studio debugging on phone

 I'm seeing error "the app doesn't support sdk version of the device (1)" from Android Studio when I try to run one of my App on a phone with USB debug just enabled. The error message is quite misleading. The phone has Android 8.1.0, which is API 27. My App build gradle file has minimum SDK version set to 15, compile and target SDK set to 28. So there is no reason of the error.

By Googling, it brought me to this Stack Overflow post: ADB Android Device Unauthorized

Usually after the USB debug just enabled, ADB won't work properly for the first time. So disconnect and reconnect USB will solve the problem. And that also solved the SDK version complain issue.