2

我正在使用 scanditsdk 创建一个扫描条形码的应用程序。我在尝试启动扫描过程时遇到问题。我有这个活动,我用一个按钮从另一个活动中调用

package com.example.scanme;

import com.mirasense.scanditsdk.ScanditSDKAutoAdjustingBarcodePicker;
import com.mirasense.scanditsdk.ScanditSDKBarcodePicker;
import com.mirasense.scanditsdk.interfaces.ScanditSDK;
import com.mirasense.scanditsdk.interfaces.ScanditSDKListener;



import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class CameraActivity extends Activity implements ScanditSDKListener {
    private ScanditSDK mBarcodePicker;

    public static final String sScanditSdkAppKey = "+rGDpqQ8EeKGdoaq71sbF2gdDH6JdOqNX1gy5vOgJKc";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        try{
            initializeAndStartBarcodeScanning();
        }
        catch (Exception e)
        {
            Log.w("Errore",e.getMessage());
        }
    }

    public void initializeAndStartBarcodeScanning() {
        try{

            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);

            requestWindowFeature(Window.FEATURE_NO_TITLE);
            try{
                ScanditSDKAutoAdjustingBarcodePicker picker = new ScanditSDKAutoAdjustingBarcodePicker(
                        this, sScanditSdkAppKey, ScanditSDKAutoAdjustingBarcodePicker.CAMERA_FACING_BACK);
            }
            catch(Exception e)
            {
                Log.w("erroreInterno",e.getMessage());
            }
        }
        catch(Exception e)
        {
            Log.w("Errore",e.getMessage());
        }

    }
    @Override
    public void didScanBarcode(String barcode, String symbology) {
        // Remove non-relevant characters that might be displayed as rectangles
        // on some devices. Be aware that you normally do not need to do this.
        // Only special GS1 code formats contain such characters.
        String cleanedBarcode = "";
        for (int i = 0 ; i < barcode.length(); i++) {
            if (barcode.charAt(i) > 30) {
                cleanedBarcode += barcode.charAt(i);
            }
        }
        Search(cleanedBarcode,symbology);
        //Toast.makeText(this, symbology + ": " + cleanedBarcode, 10000).show();

        // Example code that would typically be used in a real-world app using 
        // the Scandit SDK.
        /*
        // Access the image in which the bar code has been recognized.
        byte[] imageDataNV21Encoded = barcodePicker.getCameraPreviewImageOfFirstBarcodeRecognition();
        int imageWidth = barcodePicker.getCameraPreviewImageWidth();
        int imageHeight = barcodePicker.getCameraPreviewImageHeight();

        // Stop recognition to save resources.
        mBarcodePicker.stopScanning();
        */
    }


    public void Search(String barcodeScanned,String symbology)
    {
        //symbology is the type of barcode scanned EAN 13 UPC12 etc. etc.
        //barcodeScanned is the barcode code

        //Start SecondActivity
        /*Intent intent = new Intent(
                getApplicationContext(),
                SecondActivity.class
            );
            startActivity(intent);
        */


   }
    @Override
    public void didCancel() {
        // TODO Auto-generated method stub      
    }
    @Override
    public void didManualSearch(String arg0) {
        // TODO Auto-generated method stub

    }





}

我用这段代码来调用那个活动

ScanBtn.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v)
    {
        Intent intent=new Intent(MenuActivity.this,CameraActivity.class);
        try{startActivity(intent);}
        catch(Exception e){
            Log.w("errore",e.getMessage());
        }
    }
});

现在在 Logcat 我收到这个

05-07 01:07:53.369: D/libEGL(32132): loaded /system/lib/egl/libEGL_adreno200.so
05-07 01:07:53.369: D/libEGL(32132): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
05-07 01:07:53.379: D/libEGL(32132): loaded /system/lib/egl/libGLESv2_adreno200.so
05-07 01:07:53.439: D/OpenGLRenderer(32132): Enabling debug mode 0
05-07 01:07:57.299: D/AndroidRuntime(32132): Shutting down VM
05-07 01:07:57.299: W/dalvikvm(32132): threadid=1: thread exiting with uncaught exception (group=0x40ac6300)
05-07 01:07:57.309: E/AndroidRuntime(32132): FATAL EXCEPTION: main
05-07 01:07:57.309: E/AndroidRuntime(32132): java.lang.UnsatisfiedLinkError: Couldn't load scanditsdk-android-3.3.1: findLibrary returned null
05-07 01:07:57.309: E/AndroidRuntime(32132):    at java.lang.Runtime.loadLibrary(Runtime.java:365)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at java.lang.System.loadLibrary(System.java:535)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.mirasense.scanditsdk.ScanditSDKBarcodePicker.initializeRecognitionEngine(ScanditSDKBarcodePicker.java:1535)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.mirasense.scanditsdk.ScanditSDKBarcodePicker.<init>(ScanditSDKBarcodePicker.java:365)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.mirasense.scanditsdk.ScanditSDKBarcodePicker.<init>(ScanditSDKBarcodePicker.java:287)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.example.scanme.CameraActivity.initializeAndStartBarcodeScanning(CameraActivity.java:47)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.example.scanme.CameraActivity.onCreate(CameraActivity.java:29)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.Activity.performCreate(Activity.java:5008)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.ActivityThread.access$600(ActivityThread.java:142)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.os.Looper.loop(Looper.java:137)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at android.app.ActivityThread.main(ActivityThread.java:4931)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at java.lang.reflect.Method.invokeNative(Native Method)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at java.lang.reflect.Method.invoke(Method.java:511)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
05-07 01:07:57.309: E/AndroidRuntime(32132):    at dalvik.system.NativeStart.main(Native Method)

而且我无法理解它所说的 scandit 库无法加载的问题是什么。但实际上是在 lib 文件夹中,我已将 jar 包含在构建路径中。一个愚蠢的问题,因为我已经将 scandit 方法放在日志中的 try/catch 中,如果没有正确加载,我应该会收到一个错误。我错了吗?先感谢您

4

0 回答 0