Android. Couldn't load gpuimage-library

2019-08-13 19:49发布

问题:

I just downloaded GPUImageLibrary 1.2.3 snapshot and import the library and the sample project. In the sample app, when i pick image from gallery, everything works fine. But everytime i try to pick image from camera, the app crashes.

package jp.co.cyberagent.android.gpuimage;

public class GPUImageNativeLibrary {
    static {
         //there is the crash happened
        System.loadLibrary("gpuimage-library");
    }

    public static native void YUVtoRBGA(byte[] yuv, int width, int height, int[] out);

    public static native void YUVtoARBG(byte[] yuv, int width, int height, int[] out);
}

Here is the stacktrace

01-20 17:11:25.226: E/AndroidRuntime(15839): FATAL EXCEPTION: GLThread 3277 01-20 17:11:25.226: E/AndroidRuntime(15839): Process: jp.co.cyberagent.android.gpuimage.sample, PID: 15839 01-20 17:11:25.226: E/AndroidRuntime(15839): java.lang.UnsatisfiedLinkError: Couldn't load gpuimage-library from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/jp.co.cyberagent.android.gpuimage.sample-1.apk"],nativeLibraryDirectories=[/data/app-lib/jp.co.cyberagent.android.gpuimage.sample-1, /vendor/lib, /system/lib, /system/lib/arm]]]: findLibrary returned null 01-20 17:11:25.226: E/AndroidRuntime(15839): at java.lang.Runtime.loadLibrary(Runtime.java:358) 01-20 17:11:25.226: E/AndroidRuntime(15839): at java.lang.System.loadLibrary(System.java:526) 01-20 17:11:25.226: E/AndroidRuntime(15839): at jp.co.cyberagent.android.gpuimage.GPUImageNativeLibrary.(GPUImageNativeLibrary.java:21) 01-20 17:11:25.226: E/AndroidRuntime(15839): at jp.co.cyberagent.android.gpuimage.GPUImageRenderer$1.run(GPUImageRenderer.java:141) 01-20 17:11:25.226: E/AndroidRuntime(15839): at jp.co.cyberagent.android.gpuimage.GPUImageRenderer.runAll(GPUImageRenderer.java:126) 01-20 17:11:25.226: E/AndroidRuntime(15839): at jp.co.cyberagent.android.gpuimage.GPUImageRenderer.onDrawFrame(GPUImageRenderer.java:115) 01-20 17:11:25.226: E/AndroidRuntime(15839): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1533) 01-20 17:11:25.226: E/AndroidRuntime(15839): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1247)

I don't know what to do about this error. I think that this error is not code-related. Please give me some direction.

Sorry for my terrible english.

回答1:

You need to compile native C file located in jni folder, with ndk-build to create libary in libs folder, with extension .so.