简体   繁体   English

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader 找不到“liblivecamera.so.so”

[英]java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader couldn't find "liblivecamera.so.so"

I am working on camera application.我正在研究相机应用程序。 When I debug the application, it crashes and says当我调试应用程序时,它崩溃并说

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.tensorflow.lite.examples.detection-kuQobL0-J_-5EsHI7x5ShQ==/base.apk"],nativeLibraryDirectories=[/data/app/org.tensorflow.lite.examples.detection-kuQobL0-J_-5EsHI7x5ShQ==/lib/arm64, /data/app/org.tensorflow.lite.examples.detection-kuQobL0-J_-5EsHI7x5ShQ==/base.apk,/lib/arm64-v8a, /system/lib64. java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip 文件“/data/app/org.tensorflow.lite.examples.detection-kuQobL0-J_-5EsHI7x5ShQ==/base.apk”],nativeLibraryDirectories=[ /data/app/org.tensorflow.lite.examples.detection-kuQobL0-J_-5EsHI7x5ShQ==/lib/arm64, /data/app/org.tensorflow.lite.examples.detection-kuQobL0-J_-5EsHI7x5ShQ==/ base.apk,/lib/arm64-v8a,/system/lib64。 /vendor/lib64]]] couldn't find "liblibcamera.so.so" /vendor/lib64]]] 找不到“liblibcamera.so.so”

It is showing this error at this line of code:-它在这行代码中显示此错误:-


    static {
        System.loadLibrary("livecamera");
    }

My complete cameraview.java code我完整的 cameraview.java代码


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CameraView extends SurfaceView implements Camera.PreviewCallback, SurfaceHolder.Callback,
        OCRThread.TextRegionsListener {

    private final List<Rect> regions = new ArrayList<>();

    private Camera mCamera;
    private byte[] mVideoSource;
    private Bitmap mBackBuffer;
    private OCRThread ocrThread;

    private Paint focusPaint;
    private Rect focusRect;

    private Paint paintText;

    private float horizontalRectRation;
    private float verticalRectRation;


    static {
        System.loadLibrary("livecamera");
    }

    public CameraView(final Context context) {
        this(context, null);
    }

    public CameraView(final Context context, final AttributeSet attributes) {
        super(context, attributes);
        getHolder().addCallback(this);
        setWillNotDraw(false);
        focusPaint = new Paint();
        focusPaint.setColor(0xeed7d7d7);
        focusPaint.setStyle(Paint.Style.STROKE);
        focusPaint.setStrokeWidth(2);
        focusRect = new Rect(0, 0, 0, 0);

        paintText = new Paint();
        paintText.setColor(0xeeff0000);
        paintText.setStyle(Paint.Style.STROKE);
        paintText.setStrokeWidth(4);

        ocrThread = new OCRThread(context);
        horizontalRectRation = 1.0f;
        verticalRectRation = 1.0f;
    }

    public void setShowTextBounds(final boolean show) {
        regions.clear();
        ocrThread.setRegionsListener(show ? this : null);
        invalidate();
    }

    public void makeOCR(final OCRThread.TextRecognitionListener listener) {
        ocrThread.setTextRecognitionListener(listener);
    }

    public native void decode(final Bitmap pTarget, final byte[] pSource);


    @Override
    protected void onDraw(final Canvas canvas) {
        if (focusRect.width() > 0) {
            canvas.drawRect(focusRect, focusPaint);
        }
        if (mCamera != null) {
            mCamera.addCallbackBuffer(mVideoSource);
            drawTextBounds(canvas);
        }
    }

    private void drawTextBounds(final Canvas canvas) {
        for (Rect region : regions) {
            canvas.drawRect(region.left * horizontalRectRation, region.top * verticalRectRation,
                    region.right * horizontalRectRation, region.bottom * verticalRectRation, paintText);
        }
    }

    @Override
    public void onPreviewFrame(final byte[] bytes, final Camera camera) {
        decode(mBackBuffer, bytes);
        ocrThread.updateBitmap(mBackBuffer);
    }

    @Override
    public void surfaceCreated(final SurfaceHolder surfaceHolder) {
        try {
            mCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
            mCamera.setDisplayOrientation(90);
            mCamera.setPreviewDisplay(surfaceHolder);
            mCamera.setPreviewCallbackWithBuffer(this);
            startOcrThread();
        } catch (IOException eIOException) {
            mCamera.release();
            mCamera = null;
            throw new IllegalStateException();
        }
    }

    private void startOcrThread() {
        ocrThread.start();
    }

    @Override
    public void surfaceChanged(final SurfaceHolder surfaceHolder, final int format, final int width, final int height) {
        mCamera.stopPreview();
        Size lSize = findBestResolution();
        updateTextRectsRatio(width, height, lSize);
        PixelFormat lPixelFormat = new PixelFormat();
        PixelFormat.getPixelFormatInfo(mCamera.getParameters()
                .getPreviewFormat(), lPixelFormat);
        int lSourceSize = lSize.width * lSize.height * lPixelFormat.bitsPerPixel / 8;
        mVideoSource = new byte[lSourceSize];
        mBackBuffer = Bitmap.createBitmap(lSize.width, lSize.height,
                Bitmap.Config.ARGB_8888);
        Camera.Parameters lParameters = mCamera.getParameters();
        lParameters.setPreviewSize(lSize.width, lSize.height);
        mCamera.setParameters(lParameters);
        mCamera.addCallbackBuffer(mVideoSource);
        mCamera.startPreview();
    }

    private Size findBestResolution() {
        List<Size> lSizes = mCamera.getParameters().getSupportedPreviewSizes();
        Size lSelectedSize = mCamera.new Size(0, 0);
        for (Size lSize : lSizes) {
            if ((lSize.width >= lSelectedSize.width) && (lSize.height >= lSelectedSize.height)) {
                lSelectedSize = lSize;
            }
        }
        if ((lSelectedSize.width == 0) || (lSelectedSize.height == 0)) {
            lSelectedSize = lSizes.get(0);
        }
        return lSelectedSize;
    }

    private void updateTextRectsRatio(final int width, final int height, final Size cameraSize) {
        verticalRectRation = ((float) height) / cameraSize.width;
        horizontalRectRation = ((float) width) / cameraSize.height;
    }

    @Override
    public void surfaceDestroyed(final SurfaceHolder surfaceHolder) {
        if (mCamera != null) {
            mCamera.stopPreview();
            mCamera.release();
            mCamera = null;
            mVideoSource = null;
            mBackBuffer = null;
            stopOcrThread();
        }
    }

    private void stopOcrThread() {
        boolean retry = true;
        ocrThread.cancel();
        ocrThread.setRegionsListener(null);
        while (retry) {
            try {
                ocrThread.join();
                retry = false;
            } catch (InterruptedException e) {
            }
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            float x = event.getX();
            float y = event.getY();

            Rect touchRect = new Rect(
                    (int) (x - 100),
                    (int) (y - 100),
                    (int) (x + 100),
                    (int) (y + 100));

            final Rect targetFocusRect = new Rect(
                    touchRect.left * 2000 / this.getWidth() - 1000,
                    touchRect.top * 2000 / this.getHeight() - 1000,
                    touchRect.right * 2000 / this.getWidth() - 1000,
                    touchRect.bottom * 2000 / this.getHeight() - 1000);

            doTouchFocus(targetFocusRect);
            focusRect = touchRect;
            invalidate();

            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    focusRect = new Rect(0, 0, 0, 0);
                    invalidate();
                }
            }, 1000);
        }
        return false;
    }

    private void doTouchFocus(final Rect tfocusRect) {
        try {
            final List<Camera.Area> focusList = new ArrayList<Camera.Area>();
            Camera.Area focusArea = new Camera.Area(tfocusRect, 1000);
            focusList.add(focusArea);

            Camera.Parameters para = mCamera.getParameters();
            para.setFocusAreas(focusList);
            para.setMeteringAreas(focusList);
            mCamera.setParameters(para);
            mCamera.autoFocus(myAutoFocusCallback);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    Camera.AutoFocusCallback myAutoFocusCallback = new Camera.AutoFocusCallback() {

        @Override
        public void onAutoFocus(boolean arg0, Camera arg1) {
            if (arg0) {
                mCamera.cancelAutoFocus();
            }
        }
    };

    /**
     * {@inheritDoc}
     */
    @Override
    public void onTextRegionsRecognized(final List<Rect> textRegions) {
        regions.clear();
        regions.addAll(textRegions);
        invalidate();
    }
}

``

Your problem is the statement:你的问题是声明:

static {
        System.loadLibrary("libcamera.so");
}

System.loadLibrary is a Java method for loading a library in a platform-independant way, which means you don't have to specify the platform specific filename of the library, but instead you need to use the library name so without lib at the beginning and .so at the end. System.loadLibrary是一种 Java 方法,用于以平台无关的方式加载库,这意味着您不必指定库的平台特定文件名,而是需要使用库名称,因此开头没有lib.so最后。 Java will make it platform specific for Linux by adding both. Java 将通过添加两者使其成为特定于 Linux 的平台。

So you have to change it to所以你必须把它改成

static {
        System.loadLibrary("camera");
}

and it will work and load libcamera.so (if this library is included in your app).它将工作并加载libcamera.so (如果该库包含在您的应用程序中)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.UnsatisfiedLinkError:dalvik.system.PathClassLoader [DexPathList - java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList java.lang.UnsatisfiedLinkError…找不到“ libaacdecoder.so” - java.lang.UnsatisfiedLinkError…couldn't find “libaacdecoder.so” 如何修复UnsatisfiedLinkError:dalvik.system.PathClassLoader? - How to fix UnsatisfiedLinkError: dalvik.system.PathClassLoader? Android单元测试本地本机库:java.lang.UnsatisfiedLinkError:找不到这样的文件 - Android Unit Test local native library: java.lang.UnsatisfiedLinkError: couldn't find so file Buck-java.lang.UnsatisfiedLinkError:找不到“ libjni.so”。 怎么解决呢? - Buck - java.lang.UnsatisfiedLinkError: couldn't find “libjni.so”. How to solve it? JNI 检测到应用程序错误 java.lang.UnsatisfiedLinkError 在 android.tools.build:Z8ED1A771BC236C287AD93C699BFDD3 中找不到“xxxxx.so”。 - JNI DETECTED ERROR IN APPLICATION java.lang.UnsatisfiedLinkError couldn't find "xxxxx.so" in android.tools.build:gradle 3.6.0 应用程序启动时加载程序dalvik.system.PathClassLoader中的java.lang.ClassNotFoundException - java.lang.ClassNotFoundException in loader dalvik.system.PathClassLoader at app launch dalvik.system.PathClassLoader 不能转换为 java.net.URLClassLoader - dalvik.system.PathClassLoader cannot be cast to java.net.URLClassLoader Android:java.lang.UnsatisfiedLinkError…找不到“ lib…” - Android : java.lang.UnsatisfiedLinkError…couldn't find “lib…” java.lang.UnsatisfiedLinkError: libXrender.so.1 - java.lang.UnsatisfiedLinkError: libXrender.so.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM