I use the Google play services Visible API to read the barcode. I tried the code from the official CodeLabs example , which does not work on some (not at all) devices. Here is the Logcat post:
I/Vision﹕ Supported ABIS: [armeabi-v7a, armeabi] D/Vision﹕ Library not found: /data/data/com.google.android.gms/files/com.google.android.gms.vision/barcode/libs/armeabi-v7a/libbarhopper.so I/Vision﹕ Requesting barcode detector download. D/AndroidRuntime﹕ Shutting down VM E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: PID: 24921 java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 at android.util.SparseArray.valueAt(SparseArray.java:273) at MainActivity$1.onClick(MainActivity.java:50) at android.view.View.performClick(View.java:4780) at android.view.View$PerformClick.run(View.java:19866) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
The problem is that the device cannot find the /data/data/com.google.android.gms/files/com.google.android.gms.vision/barcode/libs/armeabi-v7a/libbarhopper.so library, and after I got an exception because of this, because the device does not detect a barcode (the list of barcodes is empty).
Here is the code:
BarcodeDetector detector = new BarcodeDetector.Builder(getApplicationContext()).build(); Bitmap bitmap = ((BitmapDrawable) mBarcodeImageView.getDrawable()).getBitmap(); Frame frame = new Frame.Builder().setBitmap(bitmap).build(); SparseArray<Barcode> barcodes = detector.detect(frame); Barcode thisCode = barcodes.valueAt(0); TextView txtView = (TextView) findViewById(R.id.txtContent); txtView.setText(thisCode.rawValue);
Google Play is updated on all devices.
Can anyone help me? How can i fix this?
source share