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
Related
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.
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
I am developing android app that uses Realm as Database but i get an error when excuting commitTransiction() method in Relm
this is the method that make a crash
if (food!= null) {
foodDb.beginTransaction();
food.setChatName(group.getName());
food.setChatImage(group.getImage());
food.setChatStatus(group.getStatus());
foodDb.commitTransaction();
}
and this is the logcat Error I got :
11-30 23:15:06.486 4480-4480/com.yourapp.chatapp E/REALM_JNI: jni: ThrowingException 2, Out of range in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp line 135(requested: 4294967295 valid: 0), .
Exception has been thrown: Out of range in /Users/cm/Realm/realm-
java/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp line
135(requested: 4294967295 valid: 0)
11-30 23:15:06.496 4480-4480/com.yourapp.chatapp E/dalvikvm: VM aborting
11-30 23:15:06.496 4480-4480/com.yourapp.chatapp A/libc: Fatal signal 6
(SIGABRT) at 0x00001180 (code=-6), thread 4480 (yourapp.chatapp)
I'm a newbie on Java and Android. I'm just planning a multimedia installation with a couple of smartphones. These are old, used smartphones with Android 2.3 (API 10) and higher (up to API 16) I'm currently testing different possibilities of streaming videos. The first method I tested is below uses a video-file which I put on a server which I access via WLAN:
...
String vidAddress = "http://www.XXXXXXXXXXXXXXX.mp4";
startVideo(vidAddress);
...
public void startVideo(String vidAddress){
// starts a video - currently from internet
vidView = (VideoView)findViewById(R.id.myVideo);
vidUri = Uri.parse(vidAddress);
vidView.setVideoURI(vidUri);
vidView.start();
}
This works on ALL API-Levels I tested: API 10-16. My problem is, that I cannot expect, that WLAN is available at the places the multimedia installation will be shown. Therefore I have to store the videos on the smartphones. This I do on the internal storage.
If I replace:
String vidAddress = "http://www.XXXXXXXXXXXXXXX.mp4";
startVideo(vidAddress);
by
String vidAddress=getFilesDir()+"/"+vidFile;
startVideo(vidAddress);
this works for API 16 but not for API 15 and older. In the Android Monitor of Android Studio I get the following error message:
07-20 14:50:23.260 23279-23279/eu.karin_daum.daum.reality D/***** Reality ONE: /data/data/eu.karin_daum.daum.reality/files/mundtest_005_2.mp4 file exists - length 1505189 bytes *****
07-20 14:50:23.260 23279-23279/eu.karin_daum.daum.reality E/MediaPlayer: Uri is /data/data/eu.karin_daum.daum.reality/files/mundtest_005_2.mp4
07-20 14:50:23.280 23279-23290/eu.karin_daum.daum.reality E/MediaPlayer: error (1, -2147483648)
07-20 14:50:23.290 23279-23279/eu.karin_daum.daum.reality E/MediaPlayer: Error (1,-2147483648)
07-20 14:50:23.290 23279-23279/eu.karin_daum.daum.reality D/VideoView: Error: 1,-2147483648
The first line is a debugging printout I've implemented in startVideo to check that the file is accessible and the length is correct. I've also tried the method 'setVideoPath' instead 'setVideoURI' with the same result: working for API 16 and not working for older Versions.
I would be grateful for any help solving my problem. Thanks, Karin
I could solve the problem, which means I found a workaround.
Apparently there is a problem (I guess due to my ignorance as newbie) with using video files from the internal storage in VideoView for API<16. Using external storage e.g.
import static android.os.Environment.DIRECTORY_MOVIES;
...
private File filePath;
...
filePath = new File(String.valueOf(Environment.getExternalStoragePublicDirectory(DIRECTORY_MOVIES)));
... then copying the video files into the directory filePath and retrieving them for playing the video
vidAddress=String.valueOf(filePath)+"/"+vidFile;
startVideo(vidAddress);
works with the method given above for all APIs I've tested (10,15,16) even without sd-card inserted.
The relevant messages on the Android Monitor in Android Studio ( e.g. for a Samsung GT S-5830i API 10) is
07-20 16:23:57.117 12548-12548/eu.karin_daum.daum.reality D/VideoView: onMeasure()
07-20 16:23:57.117 12548-12548/eu.karin_daum.daum.reality I/VideoView: Setting size: 320x399
07-20 16:24:01.312 12548-12548/eu.karin_daum.daum.reality D/***** Reality ONE: /mnt/sdcard/Movies/mundtest_005_2.mp4 file exists - length 1505189 bytes *****
07-20 16:24:01.320 12548-12548/eu.karin_daum.daum.reality D/VideoView: onMeasure()
07-20 16:24:01.320 12548-12548/eu.karin_daum.daum.reality I/VideoView: Setting size: 320x399
07-20 16:24:01.460 12548-12548/eu.karin_daum.daum.reality D/VideoView: onMeasure()
07-20 16:24:01.476 12548-12548/eu.karin_daum.daum.reality I/VideoView: Setting size: 299x399
07-20 16:24:01.500 12548-12548/eu.karin_daum.daum.reality D/MediaPlayer: getMetadata
07-20 16:24:01.500 12548-12548/eu.karin_daum.daum.reality I/VideoView: start()
07-20 16:24:01.515 12548-12548/eu.karin_daum.daum.reality I/VideoView: start()
07-20 16:29:30.929 12548-12550/eu.karin_daum.daum.reality D/dalvikvm: GC_CONCURRENT freed 359K, 48% free 3016K/5767K, external 697K/1036K, paused 3ms+3ms
Oh.. i always have error in prepare (of mediarecorder). Error tell me what prepare failed
i can't record not audio, not video ((
/*
ERROR/audio_input(34): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
02-02 12:59:04.813: ERROR/audio_input(34): VerifyAndSetParameter failed
*/
this error what always i have ((( Please can anyone help me.. i realy need help. How to fix this. I tested many examples.. i watch many post's here - but nothing not help me.
Guys - Help please :((((
Regards, Peter.
p.s. sorry for my bad english - hope you understand me.
02-02 12:59:04.623: DEBUG/dalvikvm(9334): GC_FOR_MALLOC freed 4 objects / 307296 bytes in 69ms
02-02 12:59:04.813: ERROR/audio_input(34): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
02-02 12:59:04.813: ERROR/audio_input(34): VerifyAndSetParameter failed
02-02 12:59:04.833: ERROR/CameraInput(34): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
02-02 12:59:04.833: ERROR/CameraInput(34): VerifiyAndSetParameter failed on parameter #0
02-02 12:59:04.873: WARN/AuthorDriver(34): Video encoding bit rate is set to 320000 bps
02-02 12:59:04.933: INFO/MediaRecorderJNI(9334): prepare: surface=0x20fad8 (id=1)
02-02 12:59:04.943: ERROR/PVOMXEncNode(34): PVMFOMXEncNode-Audio_AMRNB::DoPrepare(): Got Component OMX.PV.amrencnb handle
02-02 12:59:04.973: ERROR/CameraInput(34): Camera is not available
02-02 12:59:04.973: ERROR/AuthorDriver(34): Command 13 completed with error -1
02-02 12:59:04.983: ERROR/MediaRecorder(9334): prepare failed: -1
02-02 12:59:06.273: DEBUG/dalvikvm(9334): GC_FOR_MALLOC freed 201 objects / 319048 bytes in 190ms
yeah, sorry forgot about code : code here
function :
private MediaRecorder mediaRecorder;
private File file = null;
static final String PREFIX = "record";
static final String EXTENSION = ".3gpp";
private void startRecording() throws Exception {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
if (file == null) {
File rootDir = Environment.getExternalStorageDirectory();
file = File.createTempFile(PREFIX, EXTENSION, rootDir);
}
mediaRecorder.setOutputFile(file.getAbsolutePath());
mediaRecorder.prepare();
mediaRecorder.start();
Log.i("Start","RECORD STARTED");
}
so.. i never see message("record started") in logcat ((,if add videosurse and videoencode - i have error in IOException - prepare failed. I always have erros and can't find anything what can help me to solved this problem :( . I read more post's about it - and more guys have too problem.. but other guys - have not problem and all be ok.
Now im try only record audio - my emulator is handsup, and in logcat i see only erros what i write before function code. :'(
oh.. android v 2.2 im programming in exclipse galileo
red colors of errors only here :
02-03 13:36:22.783: ERROR/audio_input(34): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
02-03 13:36:22.783: ERROR/audio_input(34): VerifyAndSetParameter failed
02-03 13:36:23.004: ERROR/PVOMXEncNode(34): PVMFOMXEncNode-Audio_AMRNB::DoPrepare(): Got Component OMX.PV.amrencnb handle
02-03 13:36:23.073: ERROR/AudioFlinger(34): Error reading audio input
p.s. edited : After updating eclipse and android sdk (all patch's and other function which aviable for downloads. My camera on "all" emulators work perfectly . I can test record/capture photo/ just review on camera. One minus - if bug with preview (green lines or other similar ) than this not showing in emulator. But bugs with rotation ( when on preview all ok and than click on capture or record video we can see what our screen rotated on 90 degree) can be fixed. Hope it's help :)
Just do as per this it works fine
http://developer.android.com/guide/topics/media/index.html