0

我正在尝试使用 ZXing 库制作条形码/QR 扫描仪。如果我在三星 S9 上运行这个应用程序,它就可以工作。当我在 Vuzix M300 上运行它时,它不起作用。我尝试在 Vuzix 上运行一个带有 ZXing 的演示应用程序,这个可以工作。我的代码如下:

package com.example.scanner;

import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.google.zxing.Result;

import me.dm7.barcodescanner.zxing.ZXingScannerView;

public class MainActivity extends AppCompatActivity implements 
    ZXingScannerView.ResultHandler {
    private ZXingScannerView zXingScannerView;
    ViewGroup fl;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        fl = (ViewGroup) findViewById(R.id.fl);
        zXingScannerView = new ZXingScannerView(this);
        fl.addView(zXingScannerView);
    }

    @Override
    public void onResume() {
        super.onResume();
        zXingScannerView.setResultHandler(this);
        // You can optionally set aspect ratio tolerance level
        // that is used in calculating the optimal Camera preview size
        //zXingScannerView.setAspectTolerance(10f);
        zXingScannerView.startCamera();
    }

    public void scan(View view) {

    }

    @Override
    protected void onPause() {
        super.onPause();
        zXingScannerView.stopCamera();
    }

    @Override
    public void handleResult(Result rawResult) {
        Toast.makeText(this,rawResult.getText(), Toast.LENGTH_LONG).show();
        Log.e("scan", rawResult.getText());
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
            zXingScannerView.resumeCameraPreview(MainActivity.this);
            }
        }, 20000);
    }
}

摄像头在 Vuzix M300 上打开,但不会扫描任何内容。如果我将它与演示应用程序进行比较,似乎相机被放大了。

Vuzix 上的 logcat 如下:

03-18 09:30:49.324 2018-2018/? I/art: Late-enabling -Xcheck:jni
03-18 09:30:49.345 2018-2024/? I/art: Debugger is no longer active
03-18 09:30:49.407 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.583 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.617 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.651 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.689 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.725 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.757 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.789 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.821 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.858 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.896 2018-2018/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,sse4.1,sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.example.scanner-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.example.scanner-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-18 09:30:49.898 2018-2018/? W/System: ClassLoader referenced unknown path: /data/app/com.example.scanner-2/lib/x86
03-18 09:30:49.901 2018-2018/? I/InstantRun: starting instant run server: is main process
03-18 09:30:49.986 2018-2018/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-18 09:30:50.051 2018-2018/? I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
03-18 09:30:50.051 2018-2018/? I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
03-18 09:30:50.179 2018-2064/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
03-18 09:30:50.219 2018-2064/? I/OpenGLRenderer: Initialized EGL, version 1.4
03-18 09:30:50.220 2018-2064/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
03-18 09:30:50.278 2018-2018/? W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView

如果我尝试扫描某些内容,vuzix 的 logcat 中不会显示任何内容。

4

0 回答 0