UnsatisfiedLinkError when trying to create new instance of TessBaseAPI - java

This is a weird error because it doesn't happen every time - mostly rare - so it's difficult to debug.
This is the line where the error occurs:
TessBaseAPI tessBaseApi = new TessBaseAPI();
I use this library to connect Tesseract with Android.
The error log:
E/linker: package com.app.myapp: library "/system/lib64/libjpeg.so"
("/system/lib64/libjpeg.so") needed or dlopened by
"/system/lib64/libnativeloader.so" is not accessible for the
namespace: [name="classloader-namespace", ld_library_paths="",
default_library_paths="/data/app/com.app.myapp-4EcKvX8ZmvEUrqVJAF20Dg==/lib/arm64:/data/app/com.app.myapp-4EcKvX8ZmvEUrqVJAF20Dg==/base.apk!/lib/arm64-v8a",
permitted_paths="/data:/mnt/expand:/mnt/asec:/data/data/com.app.myapp"]
D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.app.myapp, PID: 6393
java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib64/libjpeg.so" needed or dlopened by
"/system/lib64/libnativeloader.so" is not accessible for the namespace
"classloader-namespace"
at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
at java.lang.System.loadLibrary(System.java:1657)
at com.googlecode.tesseract.android.TessBaseAPI.(TessBaseAPI.java:52)
at com.app.myapp.utils.UtilsOCR.getTessBaseAPI(UtilsOCR.java:257)
at com.app.myapp.ocr.OCRTextEvaluator.init(OCRTextEvaluator.java:381)
at com.app.myapp.ocr.OCRTextEvaluator.(OCRTextEvaluator.java:48)
at com.app.myapp.helper.NotebookWriter.init(NotebookWriter.java:530)
at com.app.myapp.helper.NotebookWriter.(NotebookWriter.java:89)
Inside TessBaseAPI class the error occurs in this line:
System.loadLibrary("jpeg");
Any kind of help would be appreciated.

Related

asynctask errors after android studio update

app have no error but asyntask.java has errors, abouth annotations, what can i do?
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
import android.compat.annotation.UnsupportedAppUsage;
Cannot resolve symbol 'MainThread'
android.annotation.Nullable' is not public in 'android.annotation'.
Cannot be accessed from outside package
Cannot resolve symbol 'WorkerThread'
Cannot resolve symbol 'annotation'
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.faysoft.shbmtal, PID: 8632
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: org.w3c.dom.DOMException: Only one root element allowed
at org.apache.harmony.xml.dom.DocumentImpl.insertChildAt(DocumentImpl.java:420)
at org.apache.harmony.xml.dom.InnerNodeImpl.appendChild(InnerNodeImpl.java:52)
at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:307)
at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:128)
Cause by line is pointing on some parsing exception, your data source changed, not Android Studio

App crash while frequent requesting mediafile with exoplayer instances

I am getting this error why frequently try to tap exoplayer instances.
normally instances releases and nulls itself on everytime.
But after some tries app freezes and crashes. I am trying to find where is the problem related
2019-04-04 11:40:36.002 540-1196/? E/BufferQueueProducer: [com..app.musicplayer/com..app.musicplayer.dashboard.DashboardMusicActivity#0] dequeueBuffer: attempting to exceed the max dequeued buffer count (2)
2019-04-04 11:40:36.110 13761-15052/com..app.musicplayer E/NativeCrypto: AppData::create pipe(2) failed: Too many open files
2019-04-04 11:40:36.121 13761-15052/com..app.musicplayer E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com..app.musicplayer, PID: 13761
java.lang.RuntimeException: javax.net.ssl.SSLException: Unable to create application data
at com.android.org.conscrypt.ConscryptFileDescriptorSocket.newSsl(ConscryptFileDescriptorSocket.java:161)
at com.android.org.conscrypt.ConscryptFileDescriptorSocket.<init>(ConscryptFileDescriptorSocket.java:152)
at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:149)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:288

android.media.AudioRecord; error

I tried to make a tuner for my guitar in android app.
For this I've to used the library AudioRecord.java, but at the compiation an error appears:
07-03 13:48:49.041 2391-2426/? E/AudioRecord: AudioFlinger could not create record track, status: -1
07-03 13:48:49.044 2391-2426/? E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -1.
07-03 13:48:49.044 2391-2426/? E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
--------- beginning of crash
07-03 13:48:49.046 2391-2426/? E/AndroidRuntime: FATAL EXCEPTION: Thread-5
Process: com.example.gaetan.tuner, PID: 2391
java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
at android.media.AudioRecord.startRecording(AudioRecord.java:976)
at com.example.gaetan.tuner.audio.CaptureThread.run(CaptureThread.java:34)
And in AudioRecord.java I can see
import android.os.ServiceManager; cannot be resolved
What can I do to change that?
The issue is likley to do with supported sample rates. The following code will give you a predicate for checking if your desired sample rate is supported.
int sampleRate = 44100;
int bufferSize = AudioRecord.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT, AudioFormat.ENCODING_PCM_16BIT);
if (bufferSize > 0) {
//the sample rate is supported so create your AudioRecord
} else {
// sample size is not supported
}
For a more advanced version featuring that supports multiple sample rates see the answer given here

java.lang.VerifyError when downloading data with jsoup in Android N

I compiled my Android app for the new Android N version and then tried to test it on an emulator. It runs normally until I try to download and parse some website data using the "jsoup" library. Then I get this java.lang.VerifyError:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.masrepus.vplanapp, PID: 6584
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.VerifyError: Verifier rejected class org.jsoup.parser.HtmlTreeBuilderState$7: boolean org.jsoup.parser.HtmlTreeBuilderState$7.process(org.jsoup.parser.Token, org.jsoup.parser.HtmlTreeBuilder) failed to verify: boolean org.jsoup.parser.HtmlTreeBuilderState$7.process(org.jsoup.parser.Token, org.jsoup.parser.HtmlTreeBuilder): [0x140B] Invalid reg type for array index (Reference: org.jsoup.nodes.Node[]) (declaration of 'org.jsoup.parser.HtmlTreeBuilderState$7' appears in /data/app/com.masrepus.vplanapp-2/base.apk)
at org.jsoup.parser.HtmlTreeBuilderState.<clinit>(HtmlTreeBuilderState.java:246)
at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:53)
at org.jsoup.parser.Parser.parseInput(Parser.java:30)
at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:81)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:517)
at org.jsoup.helper.HttpConnection.post(HttpConnection.java:174)
at com.masrepus.vplanapp.network.AsyncDownloader.updateAvailableFilesList(AsyncDownloader.java:961)
at com.masrepus.vplanapp.network.AsyncDownloader.downloadVplan(AsyncDownloader.java:237)
at com.masrepus.vplanapp.network.AsyncDownloader.doInBackground(AsyncDownloader.java:135)
at com.masrepus.vplanapp.network.AsyncDownloader.doInBackground(AsyncDownloader.java:113)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 
While researching on VerifyErrors, I came across some solutions, like cleaning the project build folder. But those solutions didn't help.
What I am wondering is, what [0x140B] Invalid reg type for array index means. This may be the thing I have to resolve, but I don't know how.
Edit:
So I dove a bit deeper into the problem and located the crash inside the block named "InBody" in org.jsoup.parser.HtmlTreeBuilderState, lines 244-759. I don't know why, but when I set breakpoints there, the program never stops there, so I have no clue at which exact position inside this block the crash happens. But as the error message speaks of some sort of array index, I figured it might be one of the 6 for-loops I found that have something to do with the data type "Element": They are at lines 305, 388, 561, 582, 602 and 640
Disable jack.
I got the same error when I enable jack. I disabled jack and compiled, no error. Then I copied jsoup source code to my project folder, enabled jack and compiled, no error. So I think it is a bug of jill, the tool to convert *.class to *.jack.

JNI WArning :Method called with exception pending

I have built the app i release mode using proguard.and I am getting this error.
01-20 15:16:37.611: W/dalvikvm(31760): JNI WARNING: JNI method called with exception pending
01-20 15:16:37.611: W/dalvikvm(31760): Pending exception is:
01-20 15:16:37.616: W/System.err(31760): java.lang.RuntimeException: Stub
When i build apk in normal way it works on my device but following release mode it does not work.
The documentation states
You must not call most JNI functions while an exception is pending. Your code is expected to notice the exception (via the function's return value, ExceptionCheck, or ExceptionOccurred) and return, or clear the exception and handle it.
You need to add error checking in your code.

Categories

Resources