compile ICS/JB camera application - native library

2019-07-06 15:37发布

问题:

I would like to use the Panorama mode that the ICS/JB camera application has. I've downloaded the source code (with resources) and managed to solve all code compilation errors but as soon as I start the application on my device (running JB), I get this error:

10-25 14:42:53.617: E/AndroidRuntime(23147): FATAL EXCEPTION: GLThread 2586
10-25 14:42:53.617: E/AndroidRuntime(23147): java.lang.UnsatisfiedLinkError: Native method not found: com.app.camera.panorama.MosaicRenderer.reset:(IIZ)V
10-25 14:42:53.617: E/AndroidRuntime(23147):    at com.app.camera.panorama.MosaicRenderer.reset(Native Method)
10-25 14:42:53.617: E/AndroidRuntime(23147):    at com.app.camera.panorama.MosaicRendererSurfaceViewRenderer.onSurfaceChanged(MosaicRendererSurfaceViewRenderer.java:49)
10-25 14:42:53.617: E/AndroidRuntime(23147):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
10-25 14:42:53.617: E/AndroidRuntime(23147):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

I do have a libjni-mosaic lib, located in armeabi-v7a/armeabi/x86 and it seems to load it fine but it probably doesn't contain the methods the MosaicRenderer implements.

I also tried compiling the CyanogenMod camera app https://github.com/CyanogenMod/android_packages_apps_Camera/tree/ics but I get the same error...

The camera itself works, for stills and video recording but as soon as I change to panorama mode, it crashes.

Can anyone maybe point me to the right jni-mosaic lib or maybe to what I'm doing wrong? Do I need to do something in order to make my app use the JNI/SO files?

回答1:

You moved the Java class MosaicRenderer to package com.app.camera.panorama, but the mosaic_renderer_jni.cpp file still has the native methods refer to com.android.camera.panorama, like

JNIEXPORT void Java_com_android_camera_panorama_MosaicRenderer_reset(

You should change the function names in the native code to reflect the new package name, e.g.

JNIEXPORT void Java_com_app_camera_panorama_MosaicRenderer_reset(


回答2:

If somebody is still interested in building Google's native camera app,I suggest you this repository https://android.googlesource.com/platform/packages/apps/Camera2/ It doesn't require building all android OS code.It helped me very much.