Lib not found error in tesseract [closed] - android

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am working with OCR android. Got samples from googling and work with android tesseract. I have the project as library and refered in another project but, when I run the project it shows the following in Logcat
07-17 10:38:47.092: ERROR/AndroidRuntime(426): FATAL EXCEPTION: main
07-17 10:38:47.092: ERROR/AndroidRuntime(426): java.lang.ExceptionInInitializerError
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.imagetotext.ImagetoText.onCreate(ImagetoText.java:21)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.os.Looper.loop(Looper.java:123)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.reflect.Method.invoke(Method.java:521)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at dalvik.system.NativeStart.main(Native Method)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): Caused by: java.lang.UnsatisfiedLinkError: Library liblept not found
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.Runtime.loadLibrary(Runtime.java:461)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.System.loadLibrary(System.java:557)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): ... 14 more
07-17 10:38:47.112: WARN/ActivityManager(60): Force finishing activity com.imagetotext/.ImagetoText
I think there is something wrong with my android.mk. Please help me fix the error.

Exception cause line is,
System.loadLibrary(“lept”);
The problem is liblept.so (shared library) file can not found on specific library path. Without seeing your code just only assumption is your code trying to load shared library liblept.so and the library is not available at that path.
Also the code you are using is either have that liblept.so file in any lib or internal package directory or you have to generate (build) that shared library by using Android-NDK.

Related

Taking picture from non-activity

I am using dummy surface in my code.It's working fine in Canvas HD running 4.2.1 but when the same app is deployed on my nexus 5/S 3 it gives RunTimeException on camera.takepicture
Here's my code
{
camera = Camera.open(cameraId);
if (camera != null)
{
SurfaceView dummy = new SurfaceView(context);
try {
camera.setPreviewDisplay(dummy.getHolder());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
camera.startPreview();
camera.takePicture(null, null, new PhotoHandler(context));
}
Logcat:
07-17 22:46:49.281: E/AndroidRuntime(481): FATAL EXCEPTION: main
07-17 22:46:49.281: E/AndroidRuntime(481): Process: com.example.ex, PID: 481
07-17 22:46:49.281: E/AndroidRuntime(481): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ex/com.example.ex.MainActivity}: java.lang.RuntimeException: takePicture failed
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.os.Handler.dispatchMessage(Handler.java:102)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.os.Looper.loop(Looper.java:136)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-17 22:46:49.281: E/AndroidRuntime(481): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 22:46:49.281: E/AndroidRuntime(481): at java.lang.reflect.Method.invoke(Method.java:515)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-17 22:46:49.281: E/AndroidRuntime(481): at dalvik.system.NativeStart.main(Native Method)
07-17 22:46:49.281: E/AndroidRuntime(481): Caused by: java.lang.RuntimeException: takePicture failed
07-17 22:46:49.281: E/AndroidRuntime(481): at android.hardware.Camera.native_takePicture(Native Method)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.hardware.Camera.takePicture(Camera.java:1245)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.hardware.Camera.takePicture(Camera.java:1190)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.example.ex.MainActivity.capturephoto(MainActivity.java:63)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.example.ex.MainActivity.onCreate(MainActivity.java:26)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.Activity.performCreate(Activity.java:5231)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
After googling and searching many questions on stackoverflow I found this and this but both snippets are used in activties .
How could I use such code in my app so that I can capture picture from background
You can use a dummy SurfaceTexture instead of a SurfaceView. This is reliable and works fine on the old camera API:
mDummyTexture = new SurfaceTexture(1); // pick a random argument for texture id
mCamera.setPreviewTexture(mDummyTexture);
mCamera.startPreview();
mCamera.takePicture(...);
Just make sure to keep mDummyTexture as a member of your class, or you may get abandoned surface errors.
As long as you don't call SurfaceTexture#updateTexImage(), you do not need an OpenGL context.
You shouldn't use a dummy SurfaceView as Android checks is the SurfaceView is displayed on the screen.
Instead, display the preview on a SurfaceView with WindowManager, with type SYSTEM_OVERLAY. Set your SurfaceView width and height to 1px and the opacity to 0 to hide the preview, and that's it!
If you plan to support only 5.0+ devices, or it's a new app that won't be available too soon, you should consider using the new android Camera2 API, which fixed many mistakes of the older API.
Hope it will help you :)
This is not possible, you need an activity to display the camera in.
Consider a transparent activity that just holds the camera view.

java.lang.VeriryError encountered

Deat developers.
I have made an application but i encounter the following problem:
Occasionally (not always - some times) i get the following error:
java.lang.VerifyError: com/google/example/games/basegameutils/GameHelper
at com.google.example.games.basegameutils.BaseGameActivity.onCreate(BaseGameActivity.java:103)
at development.nk.games.tanc.MainActivity.onCreate(MainActivity.java:97)
at android.app.Activity.performCreate(Activity.java:5047)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
at android.app.ActivityThread.access$700(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
I have looked after this problem and i read that i have to check all Libraries. I did that but the problem still is there.
The class "GameHelper" is a helper class that i use from google play services.
"MainActivity" is the main Activity my app runs. "MainActivity" extends "BaseGameActivity" which uses the "GameHelper" class.
Thank you in advance.

android camera failed when using the camera api

I'm having trouble taking a picture in android using the camera api. Using the camera intent seems to work fine, but not when I call the api directly.
Error:
java.lang.RuntimeException: takePicture failed at android.hardware.Camera.native_takePicture
Code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cameraId = findFrontFacingCamera();
camera = Camera.open(cameraId);
Parameters params = camera.getParameters();
SurfaceView dummy=new SurfaceView(context);
try {
camera.setPreviewDisplay(dummy.getHolder());
camera.startPreview();
camera.takePicture(null, photoHandler, photoHandler);
} catch (IOException e) {
camera.stopPreview();
camera.release();
}
}
private PictureCallback photoHandler = new PictureCallback() {
#Override
public void onPictureTaken(byte[] data, Camera camera) {
}
}
Manifest
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
log cat output
07-17 10:16:02.523: D/MakePhotoActivity(14591): Camera found
07-17 10:16:02.773: D/dalvikvm(14591): threadid=1: still suspended after undo (sc=1 dc=1)
07-17 10:16:18.229: D/AndroidRuntime(14591): Shutting down VM
07-17 10:16:18.229: W/dalvikvm(14591): threadid=1: thread exiting with uncaught exception (group=0x40c4f930)
07-17 10:16:18.309: E/AndroidRuntime(14591): FATAL EXCEPTION: main
07-17 10:16:18.309: E/AndroidRuntime(14591): java.lang.RuntimeException: Unable to start activity ComponentInfo{tv.fakelove.stationtostation/tv.fakelove.stationtostation.MainActivity}: java.lang.RuntimeException: takePicture failed
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.os.Looper.loop(Looper.java:137)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-17 10:16:18.309: E/AndroidRuntime(14591): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 10:16:18.309: E/AndroidRuntime(14591): at java.lang.reflect.Method.invoke(Method.java:511)
07-17 10:16:18.309: E/AndroidRuntime(14591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-17 10:16:18.309: E/AndroidRuntime(14591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-17 10:16:18.309: E/AndroidRuntime(14591): at dalvik.system.NativeStart.main(Native Method)
07-17 10:16:18.309: E/AndroidRuntime(14591): Caused by: java.lang.RuntimeException: takePicture failed
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.hardware.Camera.native_takePicture(Native Method)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.hardware.Camera.takePicture(Camera.java:1095)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.hardware.Camera.takePicture(Camera.java:1040)
07-17 10:16:18.309: E/AndroidRuntime(14591): at tv.fakelove.stationtostation.MainActivity.onCreate(MainActivity.java:59)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.Activity.performCreate(Activity.java:5104)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-17 10:16:18.309: E/AndroidRuntime(14591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
Check out the answer provided in a previous question: Android: "Camera.takePicture failed" Exception
Apparently you need to start the preview before taking a photo, which includes setting a valid preview surface (which I don't think you are doing).
Also, check out step 5-6 laid out at http://developer.android.com/reference/android/hardware/Camera.html
Obtain an instance of Camera from open(int).
Get existing (default) settings with getParameters().
If necessary, modify the returned Camera.Parameters object and call setParameters(Camera.Parameters).
If desired, call setDisplayOrientation(int).
Important: Pass a fully initialized SurfaceHolder to setPreviewDisplay(SurfaceHolder). Without a surface, the camera will
be unable to start the preview.
Important: Call startPreview() to start updating the preview surface. Preview must be started before you can take a picture.
When you want, call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback,
Camera.PictureCallback) to capture a photo. Wait for the callbacks to
provide the actual image data.
After taking a picture, preview display will have stopped. To take more photos, call startPreview() again first.
Call stopPreview() to stop updating the preview surface.
Important: Call release() to release the camera for use by other applications. Applications should release the camera immediately in
onPause() (and re-open() it in onResume()).
One thought - as you're using a dummy SurfaceView, would you need to set the width / height of the SurfaceView, to match the width / height of the preview size of the Camera?
Without the full stack trace, there's not a whole lot more I can discern that's wrong with your code.

java.io.FileNotFoundException: /data/test.xlsx (Permission denied)

i have given read write permission in manifest file ,but i am getting this exception.
07-17 15:23:47.886: W/System.err(384): java.io.FileNotFoundException: /data/test.xlsx (Permission denied)
07-17 15:23:47.906: W/System.err(384): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
07-17 15:23:47.915: W/System.err(384): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
07-17 15:23:47.915: W/System.err(384): at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
07-17 15:23:47.915: W/System.err(384): at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
07-17 15:23:47.915: W/System.err(384): at java.io.FileOutputStream.<init>(FileOutputStream.java:144)
07-17 15:23:47.915: W/System.err(384): at com.example.excelreader.MainActivity.onCreate(MainActivity.java:44)
07-17 15:23:47.915: W/System.err(384): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-17 15:23:47.926: W/System.err(384): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 15:23:47.926: W/System.err(384): at android.os.Looper.loop(Looper.java:130)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-17 15:23:47.936: W/System.err(384): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 15:23:47.936: W/System.err(384): at java.lang.reflect.Method.invoke(Method.java:507)
07-17 15:23:47.936: W/System.err(384): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-17 15:23:47.936: W/System.err(384): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-17 15:23:47.957: W/System.err(384): at dalvik.system.NativeStart.main(Native Method)
/data is not accessbile from a normal user. Infact if your run from adb
adb shell ls /data
you will get
opendir failed, Permission denied
data has the following permission
drwxrwx--x system system 2013-07-16 10:09 data

android VerifyError

i'm getting this message when i run my application i don't know why i'm getting it could any one help me. here is the logcat.
java.lang.VerifyError: com.kosh.me.Smaller
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
This happens when the build library classes conflict with those at run-time. Try performing a Clean of your project followed by a build.

Categories

Resources